Why do I need “field:” in my attribute declaration “[field:NonSerialized]”?

前端 未结 4 1331
别那么骄傲
别那么骄傲 2020-12-09 04:21

I can\'t find \"field\" listed as a C# keyword anywhere. Does anyone know the background on this?

4条回答
  •  情歌与酒
    2020-12-09 04:45

    The NonSerializedAttribute is only applicable to fields, you can use it as follows:

    [NonSerialized]
    public string myString;
    

提交回复
热议问题