Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

inheritance in c#

// Parent Class
public class A
{
    public void Method1()
    {
        // Method implementation.
    }
}
// inherit class A in class B , which makes B the child class of A
public class B : A
{ }

public class Example
{
    public static void Main()
    {
        B b = new B();
        // It will call the parent class method 
        b.Method1();
    }
}
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #inheritance
ADD COMMENT
Topic
Name
2+6 =