Thomas Darimont
Erfahrenes Mitglied
Hallo!
Schaut mal hier:
Gruß Tom
Schaut mal hier:
C#:
using System;
using System.Collections.Generic;
using System.Text;
namespace De.Tutorials.Training
{
public class CrazyStrings
{
public static void Main(string[] args)
{
DoSomeMagic();
Console.WriteLine("Hallo".Equals("ollaH"));
}
#region magic...
public static void DoSomeMagic()
{
char[] chars = "Hallo".ToCharArray();
for (int i = 0; i < chars.Length; i++)
{
InvokeMethodOn("Hallo", "SetChar", new Type[] { typeof(Int32), typeof(Char) }, new object[] {i,chars[chars.Length -i -1]});
}
}
private const System.Reflection.BindingFlags ALL_INSTANCE_BOUND_METHODS = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod;
public static object InvokeMethodOn(object instance, string methodName, Type[] signature, object[] args)
{
System.Reflection.MethodInfo methodInfo = instance.GetType().GetMethod(methodName, ALL_INSTANCE_BOUND_METHODS, null, signature, null);
return methodInfo.Invoke(instance,args);
}
#endregion
}
}
Gruß Tom