reflection_assembly1

Code :

using System;
using System.ComponentModel;
//csc reflection_assembly1.cs
using System.Reflection;
namespace ConsoleApplication1
{

class MainClass
{
public static void Main(string[] args)
{
Assembly a = Assembly.LoadFrom("test1.exe");
// Get the type names from the assembly.
Type[] types2 = a.GetTypes();
foreach (Type t in types2)
{
Console.WriteLine(t.FullName);
}
}
}
}

 

test1.cs

using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
struct SimpleStruct
{
int n1; string str1;
public SimpleStruct(int x)
{
n1 = x; str1 = "Sturct string variable";
Console.WriteLine("---1st Constructor---");
Console.WriteLine(" Received Integer " + x);
}
public SimpleStruct(string x) {
str1 = x; n1 = 12;
Console.WriteLine("---2nd Constructor---");
Console.WriteLine("Received string " + str1);
}
}
class SimpleClass
{
public SimpleClass()
{ Console.WriteLine("---parameterless class constructor---"); }
~SimpleClass() { Console.WriteLine("---parameterless class destructor---"); }
}
class Program
{
static void Main(string[] args)
{
SimpleStruct st1 = new SimpleStruct(24);
SimpleStruct st3 = new SimpleStruct("Hello struct");
SimpleClass sc1 = new SimpleClass();
Console.ReadLine();
}
}
}