-1

在 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 个参数的构造函数 error2:Level1.Level2.MyObject 不包含函数的定义

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

任何帮助表示赞赏。非常感谢。

4

1 回答 1

4

See comments in code:

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 );
     }
   }
 }
于 2013-10-22T15:49:20.547 回答