Hi, I am new to c# and reading a book about how to create classes. I was doing ok untill I read an article on
I have posted two code, one from the book, which I understand and the other from the article, which confused me. in the Book code, it first declared private variable_Name then made the public (set and get). it worked fine with me, but the article confused me in a way it first declared public variable then the Get and Set are public. Exactely opposit from what the book stated?
I was able to create an aspx page and call and set values and apply conditions if ().. for the Country public. But was not able to do the same in the public Name.
I am confused and do want to understand the point of the author's article... Is he trying to confuse his readers or what!!!
thanks for your help
Ehx
======================The Code ================
// what is in the book
private string _Country;
public string Country
{
get{return _Country;}
set{_Country= value;}
}
// what is in web article
public string Name;
private string _Name
{
get{return Name;}
set{Name= value;}
}
I have posted two code, one from the book, which I understand and the other from the article, which confused me. in the Book code, it first declared private variable_Name then made the public (set and get). it worked fine with me, but the article confused me in a way it first declared public variable then the Get and Set are public. Exactely opposit from what the book stated?
I was able to create an aspx page and call and set values and apply conditions if ().. for the Country public. But was not able to do the same in the public Name.
I am confused and do want to understand the point of the author's article... Is he trying to confuse his readers or what!!!
thanks for your help
Ehx
======================The Code ================
// what is in the book
private string _Country;
public string Country
{
get{return _Country;}
set{_Country= value;}
}
// what is in web article
public string Name;
private string _Name
{
get{return Name;}
set{Name= value;}
}