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
9 changes: 4 additions & 5 deletions docs/fundamentals/code-analysis/quality-rules/ca1863.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The following example shows two violations of the rule:
```csharp
class C
{
private static readonly string StaticField;
private static readonly string StaticField = "Format one value: {0}";

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

static void Main()
{
CompositeFormat cf = CompositeFormat.Parse(StaticField);
_ = string.Format(null, cf, 42);
_ = string.Format(null, StaticField, 42);

StringBuilder sb = new();
sb.AppendFormat(null, cf, 42);
sb.AppendFormat(null, StaticField, 42);
}
}
```
Expand Down