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

What is difference between managed and unmanaged code?

493


Should I use double or float?

493


Why do we use anonymous method in c#?

497


Why do we need serialization?

430


What basic steps are needed to display a simple report in crystal?

534






What is a method signature c#?

515


What is a cshtml file?

528


What is the difference between a variable and a literal?

532


What does dbml mean?

500


What is virtual class in C#?

544


Explain the difference between “system.array.clone()” and “system.array.copyto()” in c#?

508


What is a template class?

484


What is args c#?

532


What is the default value of object in c#?

450


What is the difference between abstraction and encapsulation in c#?

492