Skip to content

Commit 682d700

Browse files
committed
experimenting again
1 parent a8c81fc commit 682d700

File tree

1 file changed

+12
-48
lines changed

1 file changed

+12
-48
lines changed

docs/csharp/tutorials/exploration/csharp-7.yml

Lines changed: 12 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,9 @@ items:
5454
Put a paragraph before the note in case that's the root cause.
5555
5656
> [!NOTE]
57-
> The new tuples features require the <xref:System.ValueTuple> types.
58-
> You must add the NuGet package [`System.ValueTuple`](https://www.nuget.org/packages/System.ValueTuple/) in order to use it
59-
> on platforms that do not include the types.
57+
> The new tuples features require the <xref:System.ValueTuple> types. You must add the NuGet package [`System.ValueTuple`](https://www.nuget.org/packages/System.ValueTuple/) in order to use it on platforms that do not include the types.
6058
>
61-
> This is similar to other language features that rely on types
62-
> delivered in the framework. Examples include `async` and `await`
63-
> relying on the `INotifyCompletion` interface, and LINQ relying
64-
> on `IEnumerable<T>`. However, the delivery mechanism is changing
65-
> as .NET is becoming more platform independent. The .NET Framework
66-
> may not always ship on the same cadence as the language compiler. When new language
67-
> features rely on new types, those types will be available as NuGet packages when
68-
> the language features ship. As these new types are added to the .NET Standard
69-
> Library and delivered as part of the framework, the NuGet package requirement will
70-
> be removed.
59+
> This is similar to other language features that rely on types delivered in the framework. Examples include `async` and `await` relying on the `INotifyCompletion` interface, and LINQ relying on `IEnumerable<T>`. However, the delivery mechanism is changing as .NET is becoming more platform independent. The .NET Framework may not always ship on the same cadence as the language compiler. When new language features rely on new types, those types will be available as NuGet packages when the language features ship. As these new types are added to the .NET Standard Library and delivered as part of the framework, the NuGet package requirement will be removed.
7160
7261
C# provides a rich syntax for classes and structs that explains
7362
your design intent. But sometimes that rich syntax requires extra
@@ -78,52 +67,31 @@ items:
7867
The fields are not validated, and you cannot define your own methods
7968
8069
> [!NOTE]
81-
> Tuples were available before C# 7.0,
82-
> but they were inefficient and had no language support.
83-
> This meant that tuple elements could only be referenced as
84-
> `Item1`, `Item2` and so on. C# 7.0 introduces language support for tuples,
85-
> which enables semantic names for the fields of a tuple using new,
86-
> more efficient tuple types.
70+
> Tuples were available before C# 7.0, but they were inefficient and had no language support. This meant that tuple elements could only be referenced as `Item1`, `Item2` and so on. C# 7.0 introduces language support for tuples, which enables semantic names for the fields of a tuple using new more efficient tuple types.
8771
8872
You can create a tuple by assigning a value to each member:
8973
9074
[!code-csharp[UnnamedTuple](~/samples/snippets/csharp/new-in-7/program.cs#04_UnnamedTuple "Unnamed tuple")]
9175
92-
That assignment creates a tuple whose members are `Item1` and `Item2`,
93-
which you can use in the same way as <xref:System.Tuple>
94-
You can change the syntax to create a tuple that provides semantic
95-
names to each of the members of the tuple:
76+
That assignment creates a tuple whose members are `Item1` and `Item2`, which you can use in the same way as <xref:System.Tuple> You can change the syntax to create a tuple that provides semantic names to each of the members of the tuple:
9677
9778
[!code-csharp[NamedTuple](~/samples/snippets/csharp/new-in-7/program.cs#05_NamedTuple "Named tuple")]
9879
99-
The `namedLetters` tuple contains fields referred to as `Alpha` and
100-
`Beta`. Those names exist only at compile time and are not preserved
101-
when inspecting the tuple using reflection at runtime, for example.
80+
The `namedLetters` tuple contains fields referred to as `Alpha` and `Beta`. Those names exist only at compile time and are not preserved when inspecting the tuple using reflection at runtime, for example.
10281
103-
In a tuple assignment, you can also specify the names of the fields
104-
on the right-hand side of the assignment:
82+
In a tuple assignment, you can also specify the names of the fields on the right-hand side of the assignment:
10583
10684
[!code-csharp[ImplicitNamedTuple](~/samples/snippets/csharp/new-in-7/program.cs#06_ImplicitNamedTuple "Implicitly named tuple")]
10785
108-
You can specify names for the fields on both the
109-
left and right-hand side of the assignment:
86+
You can specify names for the fields on both the left and right-hand side of the assignment:
11087
11188
[!code-csharp[NamedTupleConflict](~/samples/snippets/csharp/new-in-7/program.cs#07_NamedTupleConflict "Named tuple conflict")]
11289
113-
The line above generates a warning, `CS8123`, telling you that the names on the right
114-
side of the assignment, `Alpha` and `Beta`, are ignored because they conflict
115-
with the names on the left side, `First` and `Second`.
90+
The line above generates a warning, `CS8123`, telling you that the names on the right side of the assignment, `Alpha` and `Beta`, are ignored because they conflict with the names on the left side, `First` and `Second`.
11691
117-
The examples above show the basic syntax to declare tuples. Tuples are
118-
most useful as return types for `private` and `internal` methods. Tuples
119-
provide a simple syntax for those methods to return multiple discrete values:
120-
You save the work of authoring a `class` or a `struct` that
121-
defines the type returned. There is no need to create a new type.
92+
The examples above show the basic syntax to declare tuples. Tuples are most useful as return types for `private` and `internal` methods. Tuples provide a simple syntax for those methods to return multiple discrete values: You save the work of authoring a `class` or a `struct` that defines the type returned. There is no need to create a new type.
12293
123-
Creating a tuple is more efficient and more productive.
124-
It has a simpler, lightweight syntax to define a data structure that carries
125-
more than one value. The example method below returns the minimum and maximum
126-
values found in a sequence of integers:
94+
Creating a tuple is more efficient and more productive. It has a simpler, lightweight syntax to define a data structure that carries more than one value. The example method below returns the minimum and maximum values found in a sequence of integers:
12795
12896
[!code-csharp[TupleReturningMethod](~/samples/snippets/csharp/new-in-7/program.cs#08_TupleReturningMethod "Tuple returning method")]
12997
@@ -133,15 +101,11 @@ when inspecting the tuple using reflection at runtime, for example.
133101
* You do not need to create new type.
134102
* The language enhancements removes the need to call the <xref:System.Tuple.Create``1(``0)?displayProperty=nameWithType> methods.
135103
136-
The declaration for the method provides the names for the fields of the
137-
tuple that is returned. When you call the method, the return value is a
138-
tuple whose fields are `Max` and `Min`:
104+
The declaration for the method provides the names for the fields of the tuple that is returned. When you call the method, the return value is a tuple whose fields are `Max` and `Min`:
139105
140106
[!code-csharp[CallingTupleMethod](~/samples/snippets/csharp/new-in-7/program.cs#09_CallingTupleMethod "Calling a tuple returning method")]
141107
142-
There may be times when you want to unpackage the members of a tuple that
143-
were returned from a method. You can do that by declaring separate variables
144-
for each of the values in the tuple. This is called *deconstructing* the tuple:
108+
There may be times when you want to unpackage the members of a tuple that were returned from a method. You can do that by declaring separate variables for each of the values in the tuple. This is called *deconstructing* the tuple:
145109
146110
[!code-csharp[CallingWithDeconstructor](~/samples/snippets/csharp/new-in-7/program.cs#10_CallingWithDeconstructor "Deconstructing a tuple")]
147111

0 commit comments

Comments
 (0)