void Start() { MySimpleClass myClass = new MySimpleClass(); myClass.MyInt = 10; //set being used Debug.Log(myClass.MyInt); //get being used myClass.MyString = "Syper"; Debug.Log(myClass.MyString); }
static void Main() { // Get the type of MySimpleClass. Type myType = typeof(MySimpleClass); // Get an instance of MySimpleClass. MySimpleClass myInstance = new MySimpleClass(); MyCustomBinder myCustomBinder = new MyCustomBinder(); // Get the method information for the particular overload // being sought. MethodInfo myMethod = myType.GetMethod("MyMethod", BindingFlags.Public | BindingFlags.Instance, myCustomBinder, new Type[] { typeof(string), typeof(int) }, null); Console.WriteLine(myMethod.ToString()); // Invoke the overload. myType.InvokeMember("MyMethod", BindingFlags.InvokeMethod, myCustomBinder, myInstance, new Object[] { "Testing...", (int)32 }); }
public void MethodRedefinition() { MySimpleClass c = new MySimpleClass(); c.InstanceSend(""); }
static void Main2() { // Get the type of MySimpleClass. Type myType = typeof(MySimpleClass); // Get an instance of MySimpleClass. MySimpleClass myInstance = new MySimpleClass(); CustomBinder myCustomBinder = new CustomBinder(); // Get the method information for the particular overload // being sought. MethodInfo myMethod = myType.GetMethod("MyMethod", BindingFlags.Public | BindingFlags.Instance, myCustomBinder, new Type[] {typeof(string), typeof(int)}, null); Console.WriteLine(myMethod.ToString()); // Invoke the overload. myType.InvokeMember("MyMethod", BindingFlags.InvokeMethod, myCustomBinder, myInstance, new Object[] { "Testing...", (int)32 }); }