xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to inherit a class in C#
C# Online Editor
Execute Code
More C# Sample Code
using System; namespace ExampleApp { class Program { static void Main(string[] args) { Student studentObj = new Student(); // studentObj is the object of the Student class studentObj.Name = "John"; // assign value to class propery studentObj.Age = 15; // assign value to class propery studentObj.StudentId = 11; Console.WriteLine(studentObj.Name + " is " + studentObj.Age + " years old. His student id is " + studentObj.StudentId + "." ); } } //Person class is the base (parent) class class Person { public string Name { get; set; } public int Age { get; set; } } //Student class is the derived (child) class inheriting from base (Person) class class Student : Person { public int StudentId { get; set; } } }