byte data = 0x41;
System.Console.WriteLine((char)data); // A
byte[] data = new byte[2];
data[0] = 0x41;
data[1] = 0x42;
foreach (byte item in data)
{
System.Console.WriteLine((char)item); // A B
}
// public class SubCommands
Type subCommandClass = typeof(SubCommands);
MethodInfo? subCommand = subCommandClass.GetMethod(CapitalizeFirstLetter(firstArgument));
// namespace は省略可
Type subCommandClass = Type.GetType("<namespace>.SubCommands");
MethodInfo? subCommand = subCommandClass.GetMethod(CapitalizeFirstLetter(firstArgument));
// public class SubCommands
SubCommands sc = new SubCommands();
Type subCommandClassInstance = sc.GetType();
MethodInfo? subCommand = subCommandClassInstance.GetMethod(CapitalizeFirstLetter(firstArgument));
引数を渡す
// Get the ItsMagic method and invoke with a parameter value of 100
MethodInfo magicMethod = magicType.GetMethod("ItsMagic");
object magicValue = magicMethod.Invoke(magicClassObject, new object[]{100});
var sw = new Stopwatch();
sw.Start();
for (int i = 0; i < 1000; i++)
{
Thread.Sleep(1);
}
sw.Stop();
long milliSec = sw.ElapsedMilliseconds;
System.Console.WriteLine($"{milliSec} ms"); // 1163
long ticks = sw.ElapsedTicks;
System.Console.WriteLine($"{ticks} ticks"); // 11557911
他に、restart メソッドとか使いそう。