If I store a constructor parameter's value inside a field and then want to use the value again inside the constructor, is there any reason to use the parameter vs. the field value?
Possible reasons I thought of might be convention, faster memory access, etc.
eg.
public class Shape
{
bool _myVal;
public Shape(int myVal)
{
_myVal = myVal;
// is this better...
if (myVal)
{
//do something
}
// ...than this?
if (_myVal)
{
//do something
}
}
}
Thanks

New Topic/Question
Reply



MultiQuote





|