我有以下情况:
protected MobileWalletRequestBase(XmlDocument xmlDoc, string request)
{
_xmlDoc = xmlDoc;
}
protected MobileWalletRequestBase()
: this(new XmlDocument(), ?)
{
_xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?><request/>");
}
我应该在第二个构造函数中写什么才能传递字符串值?
答案 0 :(得分:1)
一种方法是使用默认参数:
protected MobileWalletRequestBase(XmlDocument xmlDoc, string request="foo")
{
// but you're not using request in here, unclear what's needed
_xmlDoc = xmlDoc;
}
protected MobileWalletRequestBase()
: this(new XmlDocument()) // don't say anything
{
_xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?><request/>");
}