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 do I create a multi language, multi file assembly?
Structs are not reference types. Can structs have constructors?
What is the difference between method overriding and method overloading?
What is data annotation in c#?
What is difference between code access and role based security?
What is the difference between proc. Sent by val and by sub?
What is the difference between static class and sealed class in c#?
What is thread life cycle in c#?
What is difference between web and window application?
What are the steps to create an assembly and add it to the gac?
Difference between type constructor and instance constructor? What is static constructor, when it will be fired? And what is its use?
What is generic collection in c#?
Is c# different than c++?
Describe the overview of clr integration.
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?