Monday, July 7, 2014

C# Tutorial for Beginners 19 - Polymorphism in C#









1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
namespace MyProject.Examples
{
    public class Drawing
    {
        public virtual void Draw()
        {
            Console.WriteLine("This is just a generic drawing object.");
        }
    }
    public class Line : Drawing
    {
        public override void Draw()
        {
            Console.WriteLine("This is a Line.");
        }
    }
    public class Circle : Drawing
    {
        public override void Draw()
        {
            Console.WriteLine("This is a Circle.");
        }
    }
    public class Square : Drawing
    {
        public override void Draw()
        {
            Console.WriteLine("This is a Square.");
        }
    }


    class ExampleOne
    {
        public static void Main()
        {
            Drawing[] dObj = new Drawing[4];
            dObj[0] = new Line();
            dObj[1] = new Circle();
            dObj[2] = new Square();
            dObj[3] = new Drawing();

            foreach (Drawing draw in dObj)
            {
                draw.Draw();
            }
            Console.ReadKey();
        }
    }
}
























--------------------------------------------------------------

Searches related to polymorphism C#

encapsulation c#

polymorphism c# definition

polymorphism c# interview questions

runtime polymorphism c#

inheritance polymorphism c#

Introduction to inheritance, polymorphism in C#

c# - Is this the example of polymorphism?

what's the difference between inheritance and polymorphism?

C# - Types of Polymorphism in C#.Net

static polymorphism c#

polymorphism c# tutorial

polymorphism c#
IT Certification Category (English)640x480

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com


Top Online Courses From ProgrammingKnowledge

Python Course http://bit.ly/2vsuMaS
Java Coursehttp://bit.ly/2GEfQMf
Bash Coursehttp://bit.ly/2DBVF0C
Linux Coursehttp://bit.ly/2IXuil0
C Course http://bit.ly/2GQCiD1
C++ Coursehttp://bit.ly/2V4oEVJ
PHP Coursehttp://bit.ly/2XP71WH
Android Coursehttp://bit.ly/2UHih5H
C# Coursehttp://bit.ly/2Vr7HEl
JavaFx Coursehttp://bit.ly/2XMvZWA
NodeJs Coursehttp://bit.ly/2GPg7gA
Jenkins Course http://bit.ly/2Wd4l4W
Scala Coursehttp://bit.ly/2PysyA4
Bootstrap Coursehttp://bit.ly/2DFQ2yC
MongoDB Coursehttp://bit.ly/2LaCJfP
QT C++ GUI Coursehttp://bit.ly/2vwqHSZ