Suppose I have:
public class Bob
{
public int Value { get; set; }
}
I want to pass the Value member as an out parameter like>
You can achieve that, but not with a property.
public class Bob {
public int Value { get; set; } // This is a property
public int AnotherValue; // This is a field
}
You cannot use out
on Value
, but you can on AnotherValue
.
This will work
Int32.TryParse("123", out bob.AnotherValue);
But, common guidelines tells you not to make a class field public. So you should use the temporary variable approach.