Ошибка «Пространство имен не может непосредственно содержать такие члены, как поля или методы» - C#

Узнай цену своей работы

Формулировка задачи:

Добрый день! C# Visual Studio 2010 Программа выдает ошибки: Ошибка 1 Пространство имен не может непосредственно содержать такие члены, как поля или методы Ошибка 2 Требуется класс, делегат, перечисление, интерфейс или структура
Листинг программы
  1. using FsuipcSdk; // Help Studio.NET find Fsuipc class
  2. Fsuipc fsuipc = new Fsuipc(); // Instantiate our Fsuipc object
  3. bool result = false; // Return boolean for FSUIPC method calls
  4. int dwFSReq = 0; // Any version of FS is OK
  5. int dwOffset = 0x02BC; // Indicated airspeed memory offset
  6. int dwSize = 4; // Indicated airspeed memory size
  7. int token = 0; // Variable to hold returned token index
  8. int dwResult = 0; // Variable to hold returned results
  9. // Optional initialization
  10. fsuipc.FSUIPC_Initialization();
  11. // Open the connection to FSUIPC (and thus the simulator)
  12. // if result == true then everything worked OK
  13. result = fsuipc.FSUIPC_Open(dwFSReq, ref dwResult);
  14. // Submit a single read request
  15. // if result == true then everything worked OK
  16. result = fsuipc.FSUIPC_Read(dwOffset, dwSize, ref token, ref dwResult);
  17. // Process (actually perform) the request
  18. // if result == true then everything worked OK
  19. result = fsuipc.FSUIPC_Process(ref dwResult);
  20. // Get the returned value
  21. // if result == true then everything worked OK
  22. result = fsuipc.FSUIPC_Get(ref token, ref dwResult);
  23. // Adjust the IAS value as per "FSUIPC for Programmers.doc"
  24. int ias = dwResult * 128;
  25. // Close the FSUIPC connection
  26. fsuipc.FSUIPC_Close();
Пример брал из SDK:
Листинг программы
  1. public void FSUIPC_Initialization() public bool FSUIPC_Open(int dwFSReq, ref int dwResult); int SIM_ANY for any supported by FSUIPC or equivalent
  2. int SIM_FS98 FS98
  3. int SIM_FS2K FS2000
  4. int SIM_FS2K2 FS2002
  5. int SIM_CFS2 CFS2
  6. int SIM_CFS1 CFS
  7. int SIM_FLY Fly! (not supported yet, and no promises implied! int FSUIPC_Version; // HIWORD is 1000 x Version Number, minimum 1998
  8. // LOWORD is build letter, with a = 1 etc.
  9. int FSUIPC_FS_Version; // SIM_FS98, SIM_FS2K etc -- see above public bool FSUIPC_Read(int dwOffset, int dwSize, ref int Token,
  10. ref int dwResult) public bool FSUIPC_Write(int dwOffset, byte param, ref int Token,
  11. ref int dwResult)
  12. public bool FSUIPC_Write(int dwOffset, short param, ref int Token,
  13. ref int dwResult)
  14. public bool FSUIPC_Write(int dwOffset, int param, ref int Token,
  15. ref int dwResult)
  16. public bool FSUIPC_Write(int dwOffset, long param, ref int Token,
  17. ref int dwResult)
  18. public bool FSUIPC_Write(int dwOffset, int dwSize, ref byte[] param,
  19. ref int Token, ref int dwResult) public bool FSUIPC_Get(ref int Token, ref byte Result)
  20. public bool FSUIPC_Get(ref int Token, ref short Result)
  21. public bool FSUIPC_Get(ref int Token, ref int Result)
  22. public bool FSUIPC_Get(ref int Token, ref long Result)
  23. public bool FSUIPC_Get(ref int Token, int dwSize, ref byte[] Result)using FsuipcSdk; // Help Studio.NET find Fsuipc class
  24. Fsuipc fsuipc = new Fsuipc(); // Instantiate our Fsuipc object
  25. bool result = false; // Return boolean for FSUIPC method calls
  26. int dwFSReq = 0; // Any version of FS is OK
  27. int dwOffset = 0x02BC; // Indicated airspeed memory offset
  28. int dwSize = 4; // Indicated airspeed memory size
  29. int token = 0; // Variable to hold returned token index
  30. int dwResult = 0; // Variable to hold returned results
  31. // Optional initialization
  32. fsuipc.FSUIPC_Initialization();
  33. // Open the connection to FSUIPC (and thus the simulator)
  34. // if result == true then everything worked OK
  35. result = fsuipc.FSUIPC_Open(dwFSReq, ref dwResult);
  36. // Submit a single read request
  37. // if result == true then everything worked OK
  38. result = fsuipc.FSUIPC_Read(dwOffset, dwSize, ref token, ref dwResult);
  39. // Process (actually perform) the request
  40. // if result == true then everything worked OK
  41. result = fsuipc.FSUIPC_Process(ref dwResult);
  42. // Get the returned value
  43. // if result == true then everything worked OK
  44. result = fsuipc.FSUIPC_Get(ref token, ref dwResult);
  45. // Adjust the IAS value as per "FSUIPC for Programmers.doc"
  46. int ias = dwResult * 128;
  47. // Close the FSUIPC connection
  48. fsuipc.FSUIPC_Close();using FsuipcSdk; // Help Studio.NET find Fsuipc class
  49. Fsuipc fsuipc = new Fsuipc(); // Instantiate our Fsuipc object
  50. bool result = false; // Return boolean for FSUIPC method calls
  51. int dwFSReq = 0; // Any version of FS is OK
  52. int token = 0; // Variable to hold returned token index
  53. int dwResult = 0; // Variable to hold returned results
  54. // Optional initialization
  55. fsuipc.FSUIPC_Initialization();
  56. // Open the connection to FSUIPC (and thus the simulator)
  57. // if result == true then everything worked OK
  58. result = fsuipc.FSUIPC_Open(dwFSReq, ref dwResult);
  59. // Set slew mode on (required prior to location writes)
  60. // if result == true then everything worked OK
  61. result = fsuipc.FSUIPC_Write(0x05DC, 1, ref token, ref dwResult);
  62. // Set latitude
  63. // if result == true then everything worked OK
  64. result = fsuipc.FSUIPC_Write(0x0564, 4454206, ref token, ref dwResult);
  65. result = fsuipc.FSUIPC_Write(0x0560, 901120000, ref token, ref dwResult);
  66. // Set longitude
  67. // if result == true then everything worked OK
  68. result = fsuipc.FSUIPC_Write(0x056C, -991553537, ref token, ref dwResult);
  69. result = fsuipc.FSUIPC_Write(0x0568, 219480064, ref token, ref dwResult);
  70. // Write the data to FS
  71. // if result == true then everything worked OK
  72. result = fsuipc.FSUIPC_Process(ref dwResult);
  73. // Close the FSUIPC connection
  74. fsuipc.FSUIPC_Close();
Подскажите, где ошибка, чего не хватает? Так же необходимо, что бы программка опрашивала постоянно переменную ias И выводила мне ее в режиме реального времени. Спасибо!

Решение задачи: «Ошибка «Пространство имен не может непосредственно содержать такие члены, как поля или методы»»

textual
Листинг программы
  1. System.Console.WriteLine(ias);

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

13   голосов , оценка 4.154 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут
Похожие ответы