Argument Type is not CLS-compliant...class structure
I have a class as follows...The idea is to do some logic processing and return a read only object.
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,
};
}
}
If I use the above test object as paramerter in a function, I get a message Argument Type is not CLS-compliant... Any suggestions? Any other way I can achieve a read only object?
Thanks, Kamar
EDIT: (Removed previous answer.)
Having tried this myself, I strongly suspect that it's just a matter of you not putting [assembly:CLSCompliant(true)]
in the assembly declaring the Test
class. Do that, and all should be peachy.
精彩评论