感谢您帮助调试以下问题:
Toolbox
public static StdResult createLine(string extension, string site, string CSSLevel, string label)
{
...
StandardResponse res = AXLAPIServiceSingleton.getInstance().addLine(req);
**// Return of a new custom object a the result**
return new StdResult(StdResVal.SUCCESS, res.@return);
}
MyClassA
// Execute the createLine function which return a new object
StdResult resActionAssociateLine = Toolbox.createLine(selectedUserExtension, selectedUserSite, valueCreateLineCSS, valueCreateLineFirstNameLastName);
System.Diagnostics.Debug.WriteLine("Result is always null: " + resActionAssociateLine.text);
namespace CUCMAdminPortal.CiscoAXL
{
[Serializable]
public class StdResult
{
public StdResVal res;
public string text;
public StdResult(StdResVal res, string text)
{
res = this.res;
text = this.text;
}
}
}
问题是该函数总是返回一个未分配给接收对象“resActionAssociateLine”的值。该对象始终为null。当我从函数中返回一个字符串时,接收对象接收该字符串。似乎StdResult类引起了一些问题。
答案 0 :(得分:5)
您的作业在构造函数中是向后的。您希望将参数分配给实例var。
public StdResult(StdResVal res, string text)
{
this.res = res;
this.text = text;
}