I am trying to Bind a public member variable of an object to a TextBox in the UI. But when I execute the application the TextBox does not display anything.
But when I make the member variable as private and provide get set accessors to access the member variable the application works fine.
So my question is whether we can bind a public member variable of an object to a property of some other object?
This does not work:
public class Book
{
public string title;
}
This works:
public class Book
{
private string title;
public string Title
{
get { return title; }
set { title = value; }
}
}
Please clear my doubt...
Hope the question is clear....