Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Public properties without extra private property
Message
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01608537
Message ID:
01608570
Views:
34
>>Hi everybody,
>>
>>I checked this page
>>
>>http://www.dotnetperls.com/property
>>
>>and I am wondering if there is a way to use get for the public property without using private property and set?
>>
>>E.g. I have
>>
>>public string UserCode {get; set;}
>>
>>and I want to be able to have
>>
>>{get {if value == null return "" else return value.trim();} set;}
>>
>>However, this is not working and value is shown up as undefined. So, I understand how to use an extra private property but wondering if there is some shorter syntax here I can use?
>>
>>Thanks in advance.
>
>You code doesn't make sense unless 'value' is a private field - and since you have no setter I assume it is not.

How when would it have worked in that other thread we had? Or should there been also a private field?
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform