Visual Studio 无法识别公共构造函数、函数

本文关键字:构造函数 函数 识别 Studio Visual | 更新日期: 2023-09-27 18:36:29

在Visual Studio 2010中。

C# 文件1:

 namespace Level1.Level2
    {
        public class MyObject
        {
            public int _Number = 0;
            public MyObject(int number)
            {
                _Number = number;
            }
            public System.Messaging.MessageQueue FunctionA() 
            {
                  ///
          }
     }

C# 文件 2:

using Level1.Level2;
namespace AnotherNS
{
   public mainfunction()
   {
      MyObject myoj1 = new MyObject(1);
      System.Messaging.MessageQueue SomeQueue = Level1.Level2.MyObject.FunctionA();
      myoj1 .FunctionA(SomeQueue );
   }
 }

这给了我错误说

Level1.Level2.MyObject 不包含采用 1 的构造函数 参数错误 2:级别 1.级别 2.MyObject 不包含定义 对于函数错误 3:它说 Level1.Level2.MyObject 是 由于其保护级别而无法访问

对象受保护,但我将其更改为公共,功能也是如此。MyObject不是从任何东西继承而来的。

任何帮助,不胜感激。多谢。

Visual Studio 无法识别公共构造函数、函数

请参阅代码中的注释:

namespace Level1.Level2
{
    public class MyObject
    {
        public int _Number = 0;
        public MyObject(int number)
        {
            _Number = number;
        }
        public System.Messaging.MessageQueue FunctionA() 
        {
            ///////
        //missing brace
        }
      }
 }

using Level1.Level2;
namespace AnotherNS
{
   //missing class!
   public class MyClass
   {
     public mainfunction()
     {
       MyObject myoj1 = new MyObject(1);
       //call method from instance not as static
       System.Messaging.MessageQueue SomeQueue = myoj1.FunctionA();
       //I don't even know what this is supposed to do....
       //myoj1 .FunctionA(SomeQueue );
     }
   }
 }