Let's say I have a class of some object representing a Page which has two properties strTitle where the original title is stored and strUrlTitlewhere I want to store the URL friendlz title.
I want to assign the strUrlTitleonly when assigning the strTitle therefore I have used the following code.
public class Page
{
public strUrlTitle {get; private set;}
public strTitle {
get
{
return strTitle;
}
set
{
strTitle = value;
strUrlTitle = HttpUtility.UrlEncode(value.Replace(" ", "-").Trim());
}
}
}
But It appears as if when the set method i called and it assigns the strTitle value, the set method is called again and we end up in infinite loop. Hence my question is how to assign both values from one get method?
Thanks