Skip to content

Commit

Permalink
Use ThreadStaticAttribute instead of NonSerializable
Browse files Browse the repository at this point in the history
  • Loading branch information
jskeet committed Jan 3, 2023
1 parent 2c551e4 commit 0e70b82
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions standard/classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3454,23 +3454,22 @@ Although the backing field is hidden, that field may have field-targeted attribu
> ```csharp
> public class Foo
> {
> [field: NonSerialized]
> public string MySecret { get; set; }
> [field: ThreadStatic]
> public string ThreadStaticProperty { get; set; }
> }
> ```
>
> results in the field-targeted attribute `NonSerialized` being applied to the compiler-generated backing field, as if the code had been written as follows:
> results in the field-targeted attribute `ThreadStaticAttribute` being applied to the compiler-generated backing field, as if the code had been written as follows:
>
> ```csharp
> [Serializable]
> public class Foo
> {
> [NonSerialized]
> private string _mySecretBackingField;
> public string MySecret
> [ThreadStatic]
> private string _threadStaticProperty;
> public string ThreadStaticProperty
> {
> get { return _mySecretBackingField; }
> set { _mySecretBackingField = value; }
> get { return _threadStaticProperty; }
> set { _threadStaticProperty = value; }
> }
> }
> ```
Expand Down

0 comments on commit 0e70b82

Please sign in to comment.