C# Type DefaultBinder
Description
Type DefaultBinder
gets a reference to the default binder,
which implements internal rules for selecting the appropriate members
to be called by InvokeMember.
Syntax
Type.DefaultBinder
has the following syntax.
public static Binder DefaultBinder { get; }
Example
The following example gets the default binder from the DefaultBinder property, and invokes a member of MyClass by passing the DefaultBinder value as a parameter to InvokeMember.
using System;/* ww w . jav a 2s . c o m*/
using System.Reflection;
public class MyDefaultBinderSample
{
public static void Main()
{
Binder defaultBinder = Type.DefaultBinder;
MyClass myClass = new MyClass();
myClass.GetType().InvokeMember("HelloWorld", BindingFlags.InvokeMethod,
defaultBinder, myClass, new object [] {});
}
class MyClass
{
public void HelloWorld()
{
Console.WriteLine("Hello World");
}
}
}
The code above generates the following result.