using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace inheritance1 { class Program { static void Main(string[] args) { Animal a = new Animal(); a.b = 5; Console.WriteLine(a.b); dog d = new dog(); dog.b = 4; Console.WriteLine(dog.b); Console.ReadKey(); } } class Animal { public int b = 3; } class dog : Animal { } }
b
d
dog d = new dog(); d.b = 4; // note this, use instance variable not class name
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)