Why call the Overriding till two Level by Virtual Key in C#? Example.

class Student
    {
        public virtual void Name()
        {
            Console.WriteLine("Kulshresth");
        }
    }
    class Student_Details:Student
    {
        public override void Name()
        {
            Console.WriteLine("Kulshresth Kumar");
        }

        public override void Name(string name)
        {
            Console.WriteLine("Kulshresth Kumar "+) name;
        }
    }------------------------

class Program
    {
        static void Main(string[] args)
        {
            Student_Details obj = new Student_Details();
            obj.Name();
            obj.Name("Nagar");
            Console.ReadLine();
        }
    }
Share:

No comments:

Post a Comment

Friday, 28 June 2019

Why call the Overriding till two Level by Virtual Key in C#? Example.

class Student
    {
        public virtual void Name()
        {
            Console.WriteLine("Kulshresth");
        }
    }
    class Student_Details:Student
    {
        public override void Name()
        {
            Console.WriteLine("Kulshresth Kumar");
        }

        public override void Name(string name)
        {
            Console.WriteLine("Kulshresth Kumar "+) name;
        }
    }------------------------

class Program
    {
        static void Main(string[] args)
        {
            Student_Details obj = new Student_Details();
            obj.Name();
            obj.Name("Nagar");
            Console.ReadLine();
        }
    }

No comments:

Post a Comment

Popular

Total Pageviews

Archive