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
How long does it take to learn c# for unity?
How can we set the class to be inherited, but prevent the method from being over-ridden?
Can delegates be used as callbacks?
Is double a decimal?
What does do in c#?
What is dll in c#?
Who is a accessibility modifier “protected internal†available to ?
What is the purpose of a constructor in c#?
Explain the various types of classes used in c#?
Is array thread safe c#?
Please explain the basic string operations used in c#?
What is the difference between delegates and events in c#?
For read-only operation which property you have to designated?
What are partial classes and use of partial classes?
Difference between StackPanel and RelativePanel ?