When referring to a value inside a class (from within the same class), should you use the field or the property that can be accessed from other classes?
For example, which way should I be referring to a variable in my class, and why?
public static class Debug
{
private static int _NumberOfEvents = 1;
public static int NumberOfEvents
{
get
{
return _NumberOfEvents;
}
set
{
_NumberOfEvents = value;
}
}
public static void LogEvent(string Event)
{
//This way?
Console.WriteLine("Event {0}: " + Event, _NumberOfEvents);
_NumberOfEvents++;
//Or this way?
Console.WriteLine("Event {0}: " + Event, NumberOfEvents);
NumberOfEvents++;
}
}
Thanks