Monday, July 7, 2014

C# Tutorial for Beginners 19 - Polymorphism in C#

2:40 PM









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#

Written by

We are one of the initiators of the development of information technology in understanding the need for a solution that is familiar and close to us.

0 comments:

Post a Comment

 

© 2013 Klick Dev. All rights resevered.

Back To Top