Normally you use a Property to get or set a protected Field.
string protected sp_SortField=String.Empty;
string public s_SortField
{
get
{
if (sp_SortField == String.Empty
return "123";
else
return sp_SortField;
}
set
{
if (value == StringEmpty)
sp_SortField = "123";
else
sp_SortField = value;
}
)
Normaly "get" is only used for returning the sp_SortField, but such a
condition should work.
It would be better if sp_SortField is set to a valid value from the
beginning.
In you example : if (SortField == string.Empty)
- when comparing SortField you are calling get, which again calls get etc.
Also a loop!
// Now I want to have a nested property like "SortField.SomePropertyName"
not quite sure what you mean by this. SortField is allready nested as it is,
which is bad.
Hope this helps
Mark Johnson, Berlin Germany
mj*****@mj10777.de
"JollyK" <Jo****@email.com> schrieb im Newsbeitrag
news:e5**************@TK2MSFTNGP11.phx.gbl...
Hello folks,
Suppose I have a property called SortField
string SortField
{
get
{
if (SortField == string.Empty)
{
return "123";
}
return SortField;
}
set
{
SortField == value;
}
}
Now I want to have a nested property like "SortField.SomePropertyName" .
How do I do this. Can u help with a sameple code. Thanks alot.