Type Information using Reflection

Ddd
Posted by Ddd under C# category on | Points: 40 | Views : 1559
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace ConsoleApplication20jan
{
enum weekdays
{

}
struct emp
{
public void info()
{

}
}
interface i1
{

}
abstract class car
{

}

class Class9
{
static void Main()
{
//path of an assembly.
Assembly t = Assembly.LoadFrom(@"e:\jan2011\ConsoleApplication20jan\ConsoleApplication20jan\bin\Debug\ConsoleApplication20jan.exe");

Type[] z = t.GetTypes();
foreach (Type y in z)
{
if (y.IsInterface == true)
{
Console.WriteLine(y.Name + "---" + "is an interface");

}
if (y.IsAbstract == true)
{
Console.WriteLine(y.Name + "---" + "is abstract class");
}
if (y.IsClass == true)
{
Console.WriteLine(y.Name + "---" + "is a class");
}
if (y.IsValueType == true)
{
Console.WriteLine(y.Name + "---" + "is a value type");

}
}


}
}
}
//Note : i1 will be dispalyed as an interface as well an abstract class

// car will be displayed as an abstract class as well as a class

Comments or Responses

Posted by: Akiii on: 6/1/2011 Level:Bronze | Status: [Member] | Points: 10
hi,

Can you explain why "i1 will be displayed as an interface as well an abstract class " ??

Thanks and Regards
Akiii

Login to post response