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
What is difference between managed and unmanaged code?
Should I use double or float?
Why do we use anonymous method in c#?
Why do we need serialization?
What basic steps are needed to display a simple report in crystal?
What is a method signature c#?
What is a cshtml file?
What is the difference between a variable and a literal?
What does dbml mean?
What is virtual class in C#?
Explain the difference between “system.array.clone()” and “system.array.copyto()” in c#?
What is a template class?
What is args c#?
What is the default value of object in c#?
What is the difference between abstraction and encapsulation in c#?