creates instances of a value and a reference type
using System;
class Starter {
static void Main() {
int localvalue = 5;
MyClass objZ = new MyClass();
DisplayType(localvalue);
DisplayType(objZ);
}
static void DisplayType(object parameterObject) {
Type parameterType = parameterObject.GetType();
string name = parameterType.Name;
Console.WriteLine("Type is " + name);
if (name == "MyClass") {
((MyClass)parameterObject).Display();
}
}
}
class MyClass {
public void Display() {
Console.WriteLine("MyClass::Display");
}
}
Related examples in the same category