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 class is underneath the sortedlist class?
Can we call server-side code (c# or vb.net code) from javascript?
How to update the gui from another thread in c#?
Where static variables are stored?
How to open a new form on button click in Windows forms?
What is the resgen.exe tool used for?
Why we use anonymous methods in c#?
What is virtual class in C#?
What is the difference between list and dictionary in c#?
Difference between directcast and ctype.
What is _layout cshtml?
What is tuple in c#?
What are Namespaces?
Why do we use ienumerable in c#?
What floating point types is supported in C#?