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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With