Stack overflow error in C# - but how to fix it?

前端 未结 5 1159
旧时难觅i
旧时难觅i 2021-01-05 07:50

I\'ve run into a really interesting runtime bug which generates a rogue stack overflow.

I\'ve defined a structure as follows:

public enum EnumDataTy         


        
5条回答
  •  孤城傲影
    2021-01-05 08:03

    I don't understand how the first line: request.DataSize = 60;

    Doesn't cause a stack overflow - my advice would be to use backing properties:

    public class DataRequest
    {
        protected int dataSize = 0;
        protected EnumDataType enumDataType;
        public long DataSize { get { return 0; } set { dataSize = value; } }
        public EnumDataType DataType  { get { return EnumDataType.Apple; } set { enumDataType = value;} 
    }
    

提交回复
热议问题