What is type casting. Explain it with reference to classes.

Answer Posted / kiran vaidya

Type casting means converting some type to some another
type.

for example, there are three classes:

class Employee
{
//Logic for this class

}

class Manager:Employee
{
//Logic for this class

}

class Clerk:Employee
{
//Logic for this class

}


class Program
{
static void Main(string [] args)
{
Employee e=new Employee();


//Type casting
Manager m=(Manager)e;

//Or
Clerk c=(Clerk)e;

}

}

Is This Answer Correct ?    13 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I create a multi language, multi file assembly?

815


Structs are not reference types. Can structs have constructors?

668


What is the difference between method overriding and method overloading?

648


What is data annotation in c#?

679


What is difference between code access and role based security?

709


What is the difference between proc. Sent by val and by sub?

665


What is the difference between static class and sealed class in c#?

670


What is thread life cycle in c#?

674


What is difference between web and window application?

586


What are the steps to create an assembly and add it to the gac?

647


Difference between type constructor and instance constructor? What is static constructor, when it will be fired? And what is its use?

736


What is generic collection in c#?

664


Is c# different than c++?

675


Describe the overview of clr integration.

665


If I have more than one version of one assemblies, then how'll I use old version (how/where to specify version number?)in my application?

696