Hello,
I have a class that contains a member which is accessed by get property
only.
public class B {
public int I {set; get;}
public string S {set; get;}
}
public class A {
B m_b = new b();
public B B {
get {return m_b;}
}
}
I'd like to generate code for class A without instantiating a new B object.
It should look something like this:
A a = new A();
a.B.I = 3;
a.B.S = "hehe";
I don't want the code generation to look like this:
A a = new A();
B b = new B();
b.I = 3;
b.S = "hehe";
a.B = b;
How can I do this?
TIA,
Victor
Jeremy Todd - 20 Apr 2004 22:18 GMT
> Hello,
>
[quoted text clipped - 35 lines]
>
> Victor
What you want to do is use the DesignerSerializationVisibility
attribute, in the System.ComponentModel namespace:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public B B {
get {return m_b;}
}
That will tell the designer to generate code persisting the contents of
the property, not assigning the entire property itself.
Jeremy