fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Runtime.InteropServices;
  11.  
  12. namespace WindowsFormsApplication1
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19.  
  20. InitData(new byte[] { 0xC0, 0xAB, 0xCD });
  21. }
  22.  
  23.  
  24. void InitData(byte[] rawData)
  25. {
  26. GCHandle handle = GCHandle.Alloc(rawData, GCHandleType.Pinned);
  27. Setting s = (Setting)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Setting));
  28.  
  29. checkBoxIsEnable.DataBindings.Add(new Binding("checked", s, "IsEnable"));
  30. comboBoxOption.DataBindings.Add(new Binding("SelectedIndex", s, "Option"));
  31. textBoxDecData.DataBindings.Add(new Binding("Text", s, "DecimalData"));
  32. textBoxHexData.DataBindings.Add(new Binding("Text", s, "HexData"));
  33. }
  34.  
  35. }
  36.  
  37.  
  38. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  39. struct Setting
  40. {
  41. public byte control;
  42. public byte data1;
  43. public byte data2;
  44.  
  45. public bool IsEnable
  46. {
  47. get
  48. {
  49. return (control & 0x80) == 0 ? false : true;
  50. }
  51. }
  52.  
  53. public int Option
  54. {
  55. get
  56. {
  57. return (control & 0x60) >> 5;
  58. }
  59. }
  60.  
  61. public int DecimalData
  62. {
  63. get
  64. {
  65. return data1;
  66. }
  67. }
  68.  
  69. public string HexData
  70. {
  71. get
  72. {
  73. return data2.ToString("X02");
  74. }
  75. }
  76. }
  77. }
  78.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(4,14): error CS0234: The type or namespace name `Data' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(8,24): error CS0234: The type or namespace name `Tasks' does not exist in the namespace `System.Threading'. Are you missing an assembly reference?
prog.cs(9,14): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
Compilation failed: 3 error(s), 0 warnings
stdout
Standard output is empty