Skip to content

Commit b7e8a65

Browse files
authored
Update ca1863.md (#38488)
1 parent c7ad312 commit b7e8a65

File tree

1 file changed

+4
-5
lines changed
  • docs/fundamentals/code-analysis/quality-rules

1 file changed

+4
-5
lines changed

docs/fundamentals/code-analysis/quality-rules/ca1863.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The following example shows two violations of the rule:
3737
```csharp
3838
class C
3939
{
40-
private static readonly string StaticField;
40+
private static readonly string StaticField = "Format one value: {0}";
4141

4242
static void Main()
4343
{
@@ -54,15 +54,14 @@ The following example shows code that fixes both violations:
5454
```csharp
5555
class C
5656
{
57-
private static readonly string StaticField;
57+
private static readonly CompositeFormat StaticField = CompositeFormat.Parse("Format one value: {0}");
5858

5959
static void Main()
6060
{
61-
CompositeFormat cf = CompositeFormat.Parse(StaticField);
62-
_ = string.Format(null, cf, 42);
61+
_ = string.Format(null, StaticField, 42);
6362

6463
StringBuilder sb = new();
65-
sb.AppendFormat(null, cf, 42);
64+
sb.AppendFormat(null, StaticField, 42);
6665
}
6766
}
6867
```

0 commit comments

Comments
 (0)