c# 3.0 - Auto-properties: Checking/validating during the "set" -


I think we all can agree that the automatic properties in C # 3.0 are great, something like this:

  private string names; Public string name {get {return name; } Set {name = value; }}  

Less than:

  public string name {get; Set; }  

Hello!

But what should I do if I want to, change the name string using the ToUpperInvariant () method during the "setting". Do I have to return to the old C # 2.0 style to build properties?

  Private string name; Public string name {get {return name; } Set {name = value.ToUpperInvariant (); }}  

Or is there another great way to accomplish this?

Yes, you have to convert it back. An autoporty can not investigate this type.


Comments