-2

我想在 C# 中调用固定结构中的方法,如下所示:

var Test = new test1.test2.test3("parameter1","parameter2");

这在 C# 中可能吗?

这里 test1 和 test2 可以是类,而 test3 是我的方法名称,它将返回字符串文本。

如果需要删除新关键字,我可以管理。

我假设它应该是这样的:-

Public class test1
{
   Public class test2
   {
     Public string test3("parameter1","parameter2")
     {
       //Do something
     }
   }
}
4

1 回答 1

1

是的,如果 test3 是嵌套在公共结构类型 test2 中的公共结构类型,则可以在 test1 中嵌套

struct test1{
    public struct test2{
        public struct test3{
            public test3(string p1,string p2) {/*do something*/}
            //some params
        }
        //some params
    //some params
}

test1 和 test2 也可以是命名空间。

于 2013-10-21T12:23:55.823 回答