fork download
  1. using System;
  2. using System.Reflection;
  3.  
  4. namespace Tmp
  5. {
  6. public class Packer
  7. {
  8. public Packer()
  9. {
  10. }
  11.  
  12. public void PackBoolean(bool value)
  13. {
  14. }
  15.  
  16. public void PackSByte(sbyte value)
  17. {
  18. //value.GetType();
  19. Console.WriteLine("value({0}) < -1 => {1}", value, value < -1);
  20. Console.WriteLine("value({0}) < -0x20 => {1}", value, value < -0x20);
  21. Console.WriteLine("value({0}) < -0x80 => {1}", value, value < -0x80);
  22. }
  23.  
  24. public void PackObject<T>(T obj)
  25. {
  26. Type this_type = this.GetType();
  27. string obj_type_name = obj.GetType().ToString();
  28. string method_name = "Pack" + obj_type_name.Substring(obj_type_name.LastIndexOf(".") + 1);
  29. //Console.WriteLine(method_name);
  30. MethodInfo mi = this_type.GetMethod(method_name);
  31. mi.Invoke(this, new object[] { obj });
  32. }
  33.  
  34. public static void Main()
  35. {
  36. Packer packer = new Packer();
  37. packer.PackObject(true);
  38. packer.PackObject((sbyte)-0x40);
  39. }
  40. }
  41. }
  42.  
Success #stdin #stdout 0.06s 34072KB
stdin
Standard input is empty
stdout
value(-64) <     -1 => True
value(-64) <  -0x20 => True
value(-64) <  -0x80 => False