You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/csharp/misc/cs0131.md
+23-3Lines changed: 23 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,14 +33,34 @@ public class MyClass
33
33
}
34
34
publicstaticvoidMain() { }
35
35
}
36
-
```
36
+
```
37
+
38
+
## Example 2
39
+
40
+
The following sample generates CS0131 when assigning to a constant field.
37
41
38
-
## Example 2
42
+
```csharp
43
+
// CS0131b.cs
44
+
publicclassB
45
+
{
46
+
publicstaticintMain()
47
+
{
48
+
constintj=0;
49
+
j=1; // CS0131
50
+
// try the following lines instead
51
+
// int j = 0;
52
+
// j = 1;
53
+
returnj;
54
+
}
55
+
}
56
+
```
57
+
58
+
## Example 3
39
59
40
60
This error can also occur if you attempt to perform arithmetic operations on the left hand side of an assignment operator, as in the following example.
0 commit comments