Skip to content

Commit 1264b1a

Browse files
authored
Fix the style of code examples in "Using Properties (C#)" (#45178)
* Fix namespace spacing and indentation for classes * Correct the inconsistent spacing
1 parent 1dc95b5 commit 1264b1a

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

docs/csharp/programming-guide/classes-and-structs/snippets/properties/Person.cs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class Person
5151
}
5252
// </Initializer>
5353
}
54+
5455
namespace VersionFour
5556
{
5657
// <AccessorModifiers>
@@ -76,6 +77,7 @@ public class Person
7677
}
7778
// </Readonly>
7879
}
80+
7981
namespace VersionSix
8082
{
8183
// <InitOnly>
@@ -90,6 +92,7 @@ public Person() { }
9092
}
9193
// </InitOnly>
9294
}
95+
9396
namespace VersionSeven
9497
{
9598
// <Required>
@@ -130,6 +133,7 @@ public Person(string firstName, string lastName)
130133
}
131134
// </ExpressionBodiedProperty>
132135
}
136+
133137
namespace VersionNine
134138
{
135139
// <CachedBackingStore>
@@ -160,6 +164,7 @@ public string FullName
160164
}
161165
// </CachedBackingStore>
162166
}
167+
163168
namespace VersionTen
164169
{
165170
// <UseBackingFields>
@@ -206,29 +211,29 @@ namespace properties
206211

207212
// <UsingEmployeeExample>
208213
class Employee
209-
{
210-
private string _name; // the name field
211-
public string Name => _name; // the Name property
212-
}
213-
// </UsingEmployeeExample>
214+
{
215+
private string _name; // the name field
216+
public string Name => _name; // the Name property
217+
}
218+
// </UsingEmployeeExample>
214219

215-
// <ManageExample>
216-
class Manager
217-
{
218-
private string _name;
219-
public string Name => _name != null ? _name : "NA";
220-
}
221-
// </ManageExample>
220+
// <ManageExample>
221+
class Manager
222+
{
223+
private string _name;
224+
public string Name => _name != null ? _name : "NA";
225+
}
226+
// </ManageExample>
222227

223-
//<StudentExample>
224-
class Student
225-
{
226-
private string _name; // the name field
227-
public string Name // the Name property
228+
//<StudentExample>
229+
class Student
228230
{
229-
get => _name;
230-
set => _name = value;
231+
private string _name; // the name field
232+
public string Name // the Name property
233+
{
234+
get => _name;
235+
set => _name = value;
236+
}
231237
}
232-
}
233-
//</StudentExample>
238+
//</StudentExample>
234239
}

docs/csharp/programming-guide/classes-and-structs/snippets/properties/Program.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
using VersionSeven;
55

66
//<GetAccessor>
7-
var employee= new Employee();
7+
var employee = new Employee();
88
//...
99

10-
System.Console.Write(employee.Name); // the get accessor is invoked here
10+
System.Console.Write(employee.Name); // the get accessor is invoked here
1111
//</GetAccessor>
1212

1313
//<SetAccessor>
1414
var student = new Student();
15-
student.Name = "Joe"; // the set accessor is invoked here
15+
student.Name = "Joe"; // the set accessor is invoked here
1616

17-
System.Console.Write(student.Name); // the get accessor is invoked here
17+
System.Console.Write(student.Name); // the get accessor is invoked here
1818
//</SetAccessor>
1919

2020
HidingExample.TestHiding.Test();
2121

2222
// <SnippetInitialize>
2323
var aPerson = new Person("John");
24-
aPerson = new Person{ FirstName = "John"};
24+
aPerson = new Person { FirstName = "John"};
2525
// Error CS9035: Required member `Person.FirstName` must be set:
2626
//aPerson2 = new Person();
2727
// </SnippetInitialize>

0 commit comments

Comments
 (0)