Re: property inference



Ben Voigt [C++ MVP] wrote:

class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public override string ToString()
{
return this.FirstName + " " + this.LastName;
}
}

question:
so, if you do this type of inference there's no access to the
private variable? is that correct?

What inference? What private variable? The code you posted has
neither.

I guess the compiler "infers" that the properties FirstName and
LastName should have a private backing variable, and that it should
generate the code to support getting and setting these values?

(This use of the term "inference" of course conflicts with another,
usual, use of the term "inference" in c#).

.



Relevant Pages

  • Re: property inference
    ... I think inference refered to the private variable.. ... LOL ... public string FirstName ...
    (microsoft.public.dotnet.languages.csharp)
  • property inference
    ... hey all, ... public string FirstName ... public override string ToString() ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: property inference
    ... rodchar brought next idea: ... public string FirstName ... if you do this type of inference there's no access to the private variable? ... where the compiler infers that the variable "s" should be of type "String". ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: property inference
    ... rodchar wrote: ... public string FirstName ... public override string ToString() ... if you do this type of inference there's no access to the private ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Databinding to a combo box: Newbie
    ... Override the ToString function to return the 'look' that you want the ... The combobox will display the ToString output but the Selected item ... public struct stTuple ...
    (microsoft.public.dotnet.languages.csharp)