Seems that in C#, the standard practice is to use properties with get/set accessors.
In the simplified form you'll have:
public string Name { get; set; }
But you may have finer control over the access level, for example:
public string Name { get; protected set; }
Here you publicly expose the get method, but leave the set method to derived classes only.
One other benefit of using accessors instead of directly accessing a data member is that you could put a break point on a get/set method and see who executed the method.
This, however, is not possible with the { get; set; }
trick. You'll have to write the whole expanded property form:
private string m_Name = string.Empty;
public string Name
{
get { return m_Name; } // Put a happy breakpoint here
set { m_Name = value; } // or here.
}
It will be safe to reflect the same concept for Java.