Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Public properties without extra private property
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01608537
Message ID:
01608710
Vues:
38
Uhm, if you're not setting a field value in the getter why do you need a setter? What are you setting? Just leave out the setter and that way you have read only property...

+++ Rick ---

>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.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform