相关疑难解决方法(0)

在C#中从另一个体中调用一个构造函数

我需要从另一个构造函数中调用一个构造函数.我怎样才能做到这一点?

基本上

class foo {
    public foo (int x, int y)
    {
    }

    public foo (string s)
    {
        // ... do something

        // Call another constructor
        this (x, y); // Doesn't work
        foo (x, y); // neither
    }
}
Run Code Online (Sandbox Code Playgroud)

c# constructor

49
推荐指数
3
解决办法
5万
查看次数

标签 统计

c# ×1

constructor ×1