Skip to content

Commit c601820

Browse files
Fix syntax shortcomings
1 parent ba40e81 commit c601820

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

documentation/src/object-initializer.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
Use index initializers with dictionary.
66
This elegantly prevents uninitialized dictionaries.
7+
See [Object and Collection Initializers (C# Programming Guide)].
78

89
[Object and Collection Initializers (C# Programming Guide)]: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/object-and-collection-initializers#object-initializers-with-collection-read-only-property-initialization
910

@@ -14,19 +15,20 @@ var dict = new Dictionary<string, int>
1415
["key2"] = 50,
1516
};
1617
```
18+
*Good example*
1719

18-
*Not so good example*
1920
```csharp
2021
var dict = new Dictionary<string, int>();
2122
dict["key1"] = 1;
2223
dict["key2"] = 50;
2324
```
25+
*Not so good example*
2426

25-
*Deprecated way example*
2627
```csharp
2728
var dict = new Dictionary<string, int>
2829
{
2930
{ "key1", 1 },
3031
{ "key2", 50 },
3132
};
3233
```
34+
*Deprecated way example*

0 commit comments

Comments
 (0)