Thursday, March 16, 2006

.NET 247 : CallByName in C#? on microsoft.public.dotnet.languages.csharp:

using System;
using System.Reflection;

class Test
{
string name;

public Test (string name)
{
this.name=name;
}

public void PrintGreeting(string other)
{
Console.WriteLine ("{0} greets {1}", name, other);
}

static void Main()
{
Test t = new Test("Jon");
MethodInfo method = typeof(Test).GetMethod("PrintGreeting");

method.Invoke (t, new object[]{"Carsten"});
}
}

0 Comments:

Post a Comment

<< Home