Re: Properties

Tech-Archive recommends: Fix windows errors by optimizing your registry




"Joanna Carter [TeamB]" <joanna@xxxxxxxxxxxx> wrote in message
news:%23NDg%23xy6GHA.348@xxxxxxxxxxxxxxxxxxxxxxx
"Jon Slaughter" <Jon_Slaughter@xxxxxxxxxxx> a écrit dans le message de
news:
12iiv3j3ro2b8ea@xxxxxxxxxxxxxxxxxxxxx

| private string name;
| public string Name
| {
| get { return name; }
| set { name = value; }
| }
|
| Why the need to declare the same thing basically twice? If, say there
was
no
| block associated with the variable then its assumed to be a field
instead
of
| a property.

You are not declaring the same thing twice; name is a field, Name is a
property, there is not necessarily a one-to-one relationship. See my other
reply for more options.


Um, I did and you didn't state anything that was useful.

A field isn't a property. So what, I never said they were. The fact is,
AFAIK, one can distinguish a field from a property simply by having a block
after the decleration of the field(i.e., now its a property). If this is not
the case then obviously you can't.


.



Relevant Pages

  • Re: Properties
    ... | Why the need to declare the same thing basically twice? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Properties
    ... |> Why the need to declare the same thing basically twice? ... setting itself like you can with a property; a field cannot encapsulate the ... public string Name ...
    (microsoft.public.dotnet.languages.csharp)
  • Properties
    ... private string name; ... public string Name ... Why the need to declare the same thing basically twice? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Properties
    ... Public string Name ... get {return emaN;} ... Why the need to declare the same thing basically twice? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Properties
    ... |> Why the need to declare the same thing basically twice? ... setting itself like you can with a property; a field cannot encapsulate ...
    (microsoft.public.dotnet.languages.csharp)