field: prefix is used to apply attributes to fields, just like method: used with methods.
In your given code, only the first will be compiled, and the other (without the field: prefix will not.
The reason you need to add the field: prefix with the NonSerialized attribute is because it is limited to fields only:
[from metadata]
[AttributeUsage(AttributeTargets.Field, Inherited = false)] [ComVisible(true)] public sealed class NonSerializedAttribute : Attribute { public NonSerializedAttribute(); }
source share