As others have said, a stack overflow occurs because your property installer just calls itself. It might be easier to understand if you think of it as a method:
// This obviously recurses until it blows up public void SetDataType(long value) { SetDataType(value); }
As I understand it, you are trying to create normal properties, but with a default value, right?
In this case, you need the backup variables that are set by the setters, and the recipients must also return these variables. These are the variables that should receive the default values:
private long dataSize = 0; public long DataSize { get { return dataSize; } set { dataSize = value; } } private EnumDataType dataType = EnumDataType.Apple; public EnumDataType DataType { get { return dataType; } set { dataType = value; } }
Alternatively, use automatic properties, but set the default values ββin your constructor:
public long DataSize { get; set; } public EnumDataType DataType { get; set; } public DataRequest() { DataSize = 0;
source share