fork(4) download
  1. using System;
  2. using System.Runtime.InteropServices;
  3.  
  4. enum TokenType { String, Keyword, Ident, Number, Symbol }
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. // your code goes here
  11. Console.WriteLine(Marshal.SizeOf(typeof(Token0)));
  12. Console.WriteLine(Marshal.SizeOf(typeof(Token1)));
  13. Console.WriteLine(Marshal.SizeOf(typeof(Token2)));
  14. }
  15. }
  16.  
  17. [StructLayout(LayoutKind.Sequential)]
  18. class Token2
  19. {
  20. TokenType Type;
  21. object Value;
  22. int Value1;
  23. public override string ToString() { return "Type: " + Type.ToString() + "\t\tValue: " + Value.ToString(); }
  24. }
  25.  
  26. [StructLayout(LayoutKind.Sequential)]
  27. class Token1
  28. {
  29. TokenType Type;
  30. object Value;
  31. public override string ToString() { return "Type: " + Type.ToString() + "\t\tValue: " + Value.ToString(); }
  32. }
  33.  
  34. [StructLayout(LayoutKind.Sequential)]
  35. struct Token0
  36. {
  37. TokenType Type;
  38. object Value;
  39. public override string ToString() { return "Type: " + Type.ToString() + "\t\tValue: " + Value.ToString(); }
  40. }
Success #stdin #stdout 0.05s 23944KB
stdin
Standard input is empty
stdout
4
4
8