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
Define a manifest in .net?
What is the difference between properties and indexer in c#?
What is multicast delegate explain with example?
what is scope of a protected internal member variable of a c# class
When should I throw an exception?
What is the difference between System.console.WriteLine() and System.console.Write() function?example?
Suppose you have already existing application with Visual Studio 6 (VB 6, InterDev 6) and this application utilizes Windows 2000 COM+ transaction services. With this example how can you approach migrating this application to .NET?
For read-only operation which property you have to designated?
What does int parse do in c#?
Is c# a keyword?
What is int32?
If you donot specify an access modifier for a method, what is the default access modifier?
What are Namespaces?
Why to use “using” in c#?
What is cli in c#?