J
John Baro
I have a class as:
public class a :
{
private float m_b;
public float b
{
get
{
return m_b;
}
set
{
m_b = value;
}
public float compute()
{
//*****************************************************
//This method
return m_b * 369871;
//*****************************************************
//Or this method
return b * 369871;
//*****************************************************
}
}
What are peoples thoughts on the above.
Personally I prefer to use the member var instead of the property because it
removes 1 step but in some cases there is validation that needs to be done
or other so I might need to use the property. Or in some cases a property
does not have a member var.
Interested to know other peoples thoughts.
Cheers
JB
public class a :
{
private float m_b;
public float b
{
get
{
return m_b;
}
set
{
m_b = value;
}
public float compute()
{
//*****************************************************
//This method
return m_b * 369871;
//*****************************************************
//Or this method
return b * 369871;
//*****************************************************
}
}
What are peoples thoughts on the above.
Personally I prefer to use the member var instead of the property because it
removes 1 step but in some cases there is validation that needs to be done
or other so I might need to use the property. Or in some cases a property
does not have a member var.
Interested to know other peoples thoughts.
Cheers
JB