在Visual Studio 2010中。
C#File1:
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:Level1.Level2.MyObject不包含定义 对于函数error3:它的说法是Level1.Level2.MyObject 由于其保护级别无法访问
对象受保护,但我将其更改为公共,所以这些功能也是如此。 MyObject不是从任何东西继承的。
感谢任何帮助。非常感谢。
答案 0 :(得分:4)
请参阅代码中的注释:
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 );
}
}
}