我还可以从C#中的相同类的另一个构造一个重载的构造函数? [英] Can I call an overloaded constructor from another constructor of the same class in C#?

查看:91
本文介绍了我还可以从C#中的相同类的另一个构造一个重载的构造函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以调用从同一类的另一个构造函数重载的构造函数在C#?

Can I call an overloaded constructor from another constructor of the same class in C#?

推荐答案

没有,你不能构造函数后面:做到这一点,唯一的地方,你可以打电话从下再构造#后,立即是构造。
例如:

No, You can't do that, the only place you can call the constructor from another constructor in C# is immediately after ":" after the constructor. for example

class foo
{
    public foo(){}
    public foo(string s ) { }
    public foo (string s1, string s2) : this(s1) {....}

}

这篇关于我还可以从C#中的相同类的另一个构造一个重载的构造函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆