J
Jon Skeet [C# MVP]
Tamir Khason said:Little question:
I have a class A
{
public A()
{
//Whatever
}
public SomeStruct prop
{
get {return m_prop;}
set {m_prop = value;}
}
}
And structure SomeStruct
{
public string s1,s2;
public SomeStruct(string a1, a2)
{
s1 = a1;
s2 = a2;
}
}
I want to be able to assign A.prop.s1 = "Whatever"; and A.prop.s2 =
"Whatever 2"; //unable to modify rerurn value, but I want to !!!
rather then A.prop = new SomeStruct("Whatever","Whatever 2");
How to do this, ideas?
Well, you just can't, with the above. You could:
1) Have methods in A to set each part part of the property
2) Make SomeStruct a class instead
3) (Not recommended) Make m_prop public, and get rid of the property