File tree Expand file tree Collapse file tree 3 files changed +6
-21
lines changed
docs/csharp/programming-guide/classes-and-structs/snippets Expand file tree Collapse file tree 3 files changed +6
-21
lines changed Original file line number Diff line number Diff line change @@ -25,10 +25,7 @@ public class Adult : Person
2525 public Adult ( string lastName , string firstName ) : base ( lastName , firstName )
2626 { }
2727
28- static Adult ( )
29- {
30- minimumAge = 18 ;
31- }
28+ static Adult ( ) => minimumAge = 18 ;
3229
3330 // Remaining implementation of Adult class.
3431}
Original file line number Diff line number Diff line change 22
33 <PropertyGroup >
44 <OutputType >Exe</OutputType >
5- <TargetFramework >net8 .0</TargetFramework >
5+ <TargetFramework >net9 .0</TargetFramework >
66 <ImplicitUsings >enable</ImplicitUsings >
77 <Nullable >enable</Nullable >
88 </PropertyGroup >
Original file line number Diff line number Diff line change @@ -3,15 +3,9 @@ public class Taxi
33{
44 private string taxiTag ;
55
6- public Taxi ( string tag )
7- {
8- taxiTag = tag ;
9- }
6+ public Taxi ( string tag ) => taxiTag = tag ;
107
11- public override string ToString ( )
12- {
13- return $ "Taxi: { taxiTag } "; ;
14- }
8+ public override string ToString ( ) => $ "Taxi: { taxiTag } ";
159}
1610
1711class TestTaxi
@@ -42,16 +36,10 @@ public class Employee
4236 public Employee ( ) { }
4337
4438 //<Snippet9>
45- public Employee ( int annualSalary )
46- {
47- Salary = annualSalary ;
48- }
39+ public Employee ( int annualSalary ) => Salary = annualSalary ;
4940 //</Snippet9>
5041
51- public Employee ( int weeklySalary , int numberOfWeeks )
52- {
53- Salary = weeklySalary * numberOfWeeks ;
54- }
42+ public Employee ( int weeklySalary , int numberOfWeeks ) => Salary = weeklySalary * numberOfWeeks ;
5543}
5644//</Snippet3>
5745
You can’t perform that action at this time.
0 commit comments