Reputation: 14145
I'm trying to set UpperTitle populating Title.ToUpper every time Title set accessor is hit.
public string Title
{
get { return Title; }
set
{
Title = value;
UpperTitle = Title.ToUpper();
}
}
public string UpperTitle { get; protected set; }
This code compiles but I'm not sure is it ok, cause I'm getting mapping exception
problem to set property by reflection
Upvotes: 0
Views: 75
Reputation: 32481
In the get
you are calling the get
(infinite loop) again! So change your code like this:
private string _title;
public string Title
{
get { return _title; }
set
{
_title= value;
UpperTitle = string.IsNullOrEmpty(_title)? string.Empty : _title.ToUpper();
}
}
public string UpperTitle { get; protected set; }
Upvotes: 3