Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions docs/csharp/misc/cs0131.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,34 @@ public class MyClass
}
public static void Main() { }
}
```
```

## Example 2

The following sample generates CS0131 when assigning to a constant field.

## Example 2
```csharp
// CS0131b.cs
public class B
{
public static int Main()
{
const int j = 0;
j = 1; // CS0131
// try the following lines instead
// int j = 0;
// j = 1;
return j;
}
}
```

## Example 3

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.

```csharp
// CS0131b.cs
// CS0131c.cs
public class C
{
public static int Main()
Expand Down