Skip to content

Commit 869cfd1

Browse files
authored
Remove interactive snippets (#50074)
* Remove "interactive=" fromsnippets * remove interactive notes * but wait, there's more.
1 parent 62bbb2c commit 869cfd1

File tree

90 files changed

+434
-465
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+434
-465
lines changed

docs/csharp/fundamentals/object-oriented/objects.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ Because classes are reference types, a variable of a class object holds a refere
1919

2020
Instances of classes are created by using the [`new` operator](../../language-reference/operators/new-operator.md). In the following example, `Person` is the type and `person1` and `person2` are instances, or objects, of that type.
2121

22-
:::code language="csharp" source="./snippets/objects/Program.cs" interactive="try-dotnet":::
22+
:::code language="csharp" source="./snippets/objects/Program.cs":::
2323

2424
Because structs are value types, a variable of a struct object holds a copy of the entire object. Instances of structs can also be created by using the `new` operator, but this isn't required, as shown in the following example:
2525

26-
:::code language="csharp" source="./snippets/objects/Application.cs" interactive="try-dotnet":::
26+
:::code language="csharp" source="./snippets/objects/Application.cs":::
2727

2828
The memory for both `p1` and `p2` is allocated on the thread stack. That memory is reclaimed along with the type or method in which it's declared. This is one reason why structs are copied on assignment. By contrast, the memory that is allocated for a class instance is automatically reclaimed (garbage collected) by the common language runtime when all references to the object are out of scope. It isn't possible to deterministically destroy a class object like you can in C++. For more information about garbage collection in .NET, see [Garbage Collection](../../../standard/garbage-collection/index.md).
2929

docs/csharp/how-to/compare-strings.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ The <xref:System.StringComparison?displayProperty=fullName> enumeration fields r
2727
- **Ordinal**: Compare strings using ordinal (binary) sort rules.
2828
- **OrdinalIgnoreCase**: Compare strings using ordinal (binary) sort rules and ignoring the case of the strings being compared.
2929

30-
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]
31-
3230
When you compare strings, you define an order among them. Comparisons are used to sort a sequence of strings. Once the sequence is in a known order, it's easier to search, both for software and for humans. Other comparisons might check if strings are the same. These sameness checks are similar to equality, but some differences, such as case differences, might be ignored.
3331

3432
## Default ordinal comparisons
@@ -38,7 +36,7 @@ By default, the most common operations:
3836
- <xref:System.String.Equals%2A?displayProperty=nameWithType>
3937
- <xref:System.String.op_Equality%2A?displayProperty=nameWithType> and <xref:System.String.op_Inequality%2A?displayProperty=nameWithType>, that is, [equality operators `==` and `!=`](../language-reference/operators/equality-operators.md#string-equality), respectively perform a case-sensitive, ordinal comparison. <xref:System.String.Equals%2A?displayProperty=nameWithType> has an overload where a <xref:System.StringComparison> argument can be provided to alter its sorting rules. The following example demonstrates that:
4038

41-
:::code language="csharp" interactive="try-dotnet-method" source="./snippets/strings/CompareStrings.cs" id="Snippet1":::
39+
:::code language="csharp" source="./snippets/strings/CompareStrings.cs" id="Snippet1":::
4240

4341
The default ordinal comparison doesn't take linguistic rules into account when comparing strings. It compares the binary value of each <xref:System.Char> object in two strings. As a result, the default ordinal comparison is also case-sensitive.
4442

@@ -51,23 +49,23 @@ You can use the [`is`](../language-reference/operators/is.md) operator and a [co
5149
The <xref:System.String.Equals(System.String,System.StringComparison)?displayProperty=nameWithType> method enables you to specify a <xref:System.StringComparison> value of
5250
<xref:System.StringComparison.OrdinalIgnoreCase?displayProperty=nameWithType> for a case-insensitive ordinal comparison. There's also a static <xref:System.String.Compare(System.String,System.String,System.StringComparison)?displayProperty=nameWithType> method that performs a case-insensitive ordinal comparison if you specify a value of <xref:System.StringComparison.OrdinalIgnoreCase?displayProperty=nameWithType> for the <xref:System.StringComparison> argument. These comparisons are shown in the following code:
5351

54-
:::code language="csharp" interactive="try-dotnet-method" source="./snippets/strings/CompareStrings.cs" id="Snippet2":::
52+
:::code language="csharp" source="./snippets/strings/CompareStrings.cs" id="Snippet2":::
5553

5654
These methods use the casing conventions of the [invariant culture](xref:System.Globalization.CultureInfo.InvariantCulture) when performing a case-insensitive ordinal comparison.
5755

5856
## Linguistic comparisons
5957

6058
Many string comparison methods (such as <xref:System.String.StartsWith%2A?displayProperty=nameWithType>) use linguistic rules for the _current culture_ by default to order their inputs. This linguistic comparison is sometimes referred to as "word sort order." When you perform a linguistic comparison, some nonalphanumeric Unicode characters might have special weights assigned. For example, the hyphen "-" might have a small weight assigned to it so that "co-op" and "coop" appear next to each other in sort order. Some nonprinting control characters might be ignored. In addition, some Unicode characters might be equivalent to a sequence of <xref:System.Char> instances. The following example uses the phrase "They dance in the street." in German with the "ss" (U+0073 U+0073) in one string and 'ß' (U+00DF) in another. Linguistically (in Windows), "ss" is equal to the German Esszet: 'ß' character in both the "en-US" and "de-DE" cultures.
6159

62-
:::code language="csharp" interactive="try-dotnet-method" source="./snippets/strings/CompareStrings.cs" id="Snippet3":::
60+
:::code language="csharp" source="./snippets/strings/CompareStrings.cs" id="Snippet3":::
6361

6462
On Windows, before .NET 5, the sort order of "cop", "coop", and "co-op" changes when you change from a linguistic comparison to an ordinal comparison. The two German sentences also compare differently using the different comparison types. Before .NET 5, the .NET globalization APIs used [National Language Support (NLS)](/windows/win32/intl/national-language-support) libraries. In .NET 5 and later versions, the .NET globalization APIs use [International Components for Unicode (ICU)](https://icu.unicode.org/) libraries, which unify .NET's globalization behavior across all supported operating systems.
6563

6664
## Comparisons using specific cultures
6765

6866
The following example stores <xref:System.Globalization.CultureInfo> objects for the en-US and de-DE cultures. The comparisons are performed using a <xref:System.Globalization.CultureInfo> object to ensure a culture-specific comparison. The culture used affects linguistic comparisons. The following example shows the results of comparing the two German sentences using the "en-US" culture and the "de-DE" culture:
6967

70-
:::code language="csharp" interactive="try-dotnet-method" source="./snippets/strings/CompareStrings.cs" id="Snippet4":::
68+
:::code language="csharp" source="./snippets/strings/CompareStrings.cs" id="Snippet4":::
7169

7270
Culture-sensitive comparisons are typically used to compare and sort strings input by users with other strings input by users. The characters and sorting conventions of these strings might vary depending on the locale of the user's computer. Even strings that contain identical characters might sort differently depending on the culture of the current thread.
7371

@@ -77,21 +75,21 @@ The following examples show how to sort and search for strings in an array using
7775

7876
The following example shows how to sort an array of strings using the current culture:
7977

80-
:::code language="csharp" interactive="try-dotnet-method" source="./snippets/strings/CompareStrings.cs" id="Snippet5":::
78+
:::code language="csharp" source="./snippets/strings/CompareStrings.cs" id="Snippet5":::
8179

8280
Once the array is sorted, you can search for entries using a binary search. A binary search starts in the middle of the collection to determine which half of the collection would contain the sought string. Each subsequent comparison subdivides the remaining part of the collection in half. The array is sorted using the <xref:System.StringComparer.CurrentCulture?displayProperty=nameWithType>. The local function `ShowWhere` displays information about where the string was found. If the string wasn't found, the returned value indicates where it would be if it were found.
8381

84-
:::code language="csharp" interactive="try-dotnet-method" source="./snippets/strings/CompareStrings.cs" id="Snippet6":::
82+
:::code language="csharp" source="./snippets/strings/CompareStrings.cs" id="Snippet6":::
8583

8684
## Ordinal sorting and searching in collections
8785

8886
The following code uses the <xref:System.Collections.Generic.List%601?displayProperty=nameWithType> collection class to store strings. The strings are sorted using the <xref:System.Collections.Generic.List%601.Sort%2A?displayProperty=nameWithType> method. This method needs a delegate that compares and orders two strings. The <xref:System.String.CompareTo%2A?displayProperty=nameWithType> method provides that comparison function. Run the sample and observe the order. This sort operation uses an ordinal case-sensitive sort. You would use the static <xref:System.String.Compare%2A?displayProperty=nameWithType> methods to specify different comparison rules.
8987

90-
:::code language="csharp" interactive="try-dotnet-method" source="./snippets/strings/CompareStrings.cs" id="Snippet7":::
88+
:::code language="csharp" source="./snippets/strings/CompareStrings.cs" id="Snippet7":::
9189

9290
Once sorted, the list of strings can be searched using a binary search. The following sample shows how to search the sorted list using the same comparison function. The local function `ShowWhere` shows where the sought text is or would be:
9391

94-
:::code language="csharp" interactive="try-dotnet-method" source="./snippets/strings/CompareStrings.cs" id="Snippet8":::
92+
:::code language="csharp" source="./snippets/strings/CompareStrings.cs" id="Snippet8":::
9593

9694
Always make sure to use the same type of comparison for sorting and searching. Using different comparison types for sorting and searching produces unexpected results.
9795

docs/csharp/how-to/concatenate-multiple-strings.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,26 @@ ms.custom: copilot-scenario-highlight
1212

1313
*Concatenation* is the process of appending one string to the end of another string. You concatenate strings by using the `+` operator. For string literals and string constants, concatenation occurs at compile time; no run-time concatenation occurs. For string variables, concatenation occurs only at run time.
1414

15-
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]
16-
1715
> [!TIP]
1816
> You can use AI assistance to [concatenate strings](#use-ai-to-concatenate-strings).
1917
2018
## String literals
2119

2220
The following example splits a long string literal into smaller strings to improve readability in the source code. The code concatenates the smaller strings to create the long string literal. The parts are concatenated into a single string at compile time. There's no run-time performance cost regardless of the number of strings involved.
2321

24-
:::code language="csharp" interactive="try-dotnet-method" source="./snippets/strings/Concatenate.cs" id="Snippet1":::
22+
:::code language="csharp" source="./snippets/strings/Concatenate.cs" id="Snippet1":::
2523

2624
## `+` and `+=` operators
2725

2826
To concatenate string variables, you can use the `+` or `+=` operators, [string interpolation](../language-reference/tokens/interpolated.md) or the <xref:System.String.Format%2A?displayProperty=nameWithType>, <xref:System.String.Concat%2A?displayProperty=nameWithType>, <xref:System.String.Join%2A?displayProperty=nameWithType> or <xref:System.Text.StringBuilder.Append%2A?displayProperty=nameWithType> methods. The `+` operator is easy to use and makes for intuitive code. Even if you use several `+` operators in one statement, the string content is copied only once. The following code shows examples of using the `+` and `+=` operators to concatenate strings:
2927

30-
:::code language="csharp" interactive="try-dotnet-method" source="./snippets/strings/Concatenate.cs" id="Snippet2":::
28+
:::code language="csharp" source="./snippets/strings/Concatenate.cs" id="Snippet2":::
3129

3230
## String interpolation
3331

3432
In some expressions, it's easier to concatenate strings using string interpolation, as the following code shows:
3533

36-
:::code language="csharp" interactive="try-dotnet-method" source="./snippets/strings/Concatenate.cs" id="Snippet3":::
34+
:::code language="csharp" source="./snippets/strings/Concatenate.cs" id="Snippet3":::
3735

3836
> [!NOTE]
3937
> In string concatenation operations, the C# compiler treats a null string the same as an empty string.
@@ -48,15 +46,15 @@ Another method to concatenate strings is <xref:System.String.Format%2A?displayPr
4846

4947
In other cases, you might be combining strings in a loop where the actual number of source strings can be large. The <xref:System.Text.StringBuilder> class was designed for these scenarios. The following code uses the <xref:System.Text.StringBuilder.Append%2A> method of the <xref:System.Text.StringBuilder> class to concatenate strings.
5048

51-
:::code language="csharp" interactive="try-dotnet-method" source="./snippets/strings/Concatenate.cs" id="Snippet4":::
49+
:::code language="csharp" source="./snippets/strings/Concatenate.cs" id="Snippet4":::
5250

5351
You can read more about the [reasons to choose string concatenation or the `StringBuilder` class](/dotnet/api/system.text.stringbuilder#the-string-and-stringbuilder-types).
5452

5553
## `String.Concat` or `String.Join`
5654

5755
Another option to join strings from a collection is to use <xref:System.String.Concat%2A?displayProperty=nameWithType> method. Use <xref:System.String.Join%2A?displayProperty=nameWithType> method if a delimiter should separate source strings. The following code combines an array of words using both methods:
5856

59-
:::code language="csharp" interactive="try-dotnet-method" source="./snippets/strings/Concatenate.cs" id="Snippet5":::
57+
:::code language="csharp" source="./snippets/strings/Concatenate.cs" id="Snippet5":::
6058

6159
## LINQ and `Enumerable.Aggregate`
6260

@@ -66,7 +64,7 @@ the source strings using a lambda expression. The lambda expression does the
6664
work to add each string to the existing accumulation. The following example
6765
combines an array of words, adding a space between each word in the array:
6866

69-
:::code language="csharp" interactive="try-dotnet-method" source="./snippets/strings/Concatenate.cs" id="Snippet6":::
67+
:::code language="csharp" source="./snippets/strings/Concatenate.cs" id="Snippet6":::
7068

7169
This option can cause more allocations than other methods for concatenating collections, as it creates an intermediate string for each iteration. If optimizing performance is critical, consider the [`StringBuilder`](#stringbuilder) class or the [`String.Concat` or `String.Join`](#stringconcat-or-stringjoin) method to concatenate a collection, instead of `Enumerable.Aggregate`.
7270

0 commit comments

Comments
 (0)