我有一个类如下......想法是做一些逻辑处理并返回一个只读对象.
public class Test
{
public object property1 { get; private set; }
public string property2 { get; private set; }
private Test(){}
public static Test GetTest(XDocument document)
{
if (document== null)
return null;
return new Test
{
property1 = l_document.Element("something").value,
property2 = l_document.Element("anotherthing").value,
};
}
}
Run Code Online (Sandbox Code Playgroud)
如果我在函数中使用上面的测试对象作为参数,我得到一条消息Argument Type不符合CLS ......有什么建议吗?我可以通过其他任何方式实现只读对象吗?
谢谢,Kamar
c# ×1