I was reading the Essential C# 3.0 book and am wondering if this is a good way to check delegates for null?:
class Thermostat
{
public delegate void Temperat
I just see a bit of refactoring that could be done but otherwise it looks good...
class Thermostat
{
public delegate void TemperatureChangeHandler ( float newTemperature );
public TemperatureChangeHandler OnTemperatureChange { get; set; }
float currentTemperature;
public float CurrentTemperature
{
get { return this.currentTemperature; }
set
{
if (currentTemperature != value)
{
currentTemperature = value;
if (this.OnTemperatureChange != null )
{
this.OnTemperatureChange.Invoke( value );
}
}
}
}
}