Skip to content

Commit 8073ec4

Browse files
authored
Change "alignment" to "width" (#45780)
1 parent a0329dc commit 8073ec4

File tree

18 files changed

+312
-328
lines changed

18 files changed

+312
-328
lines changed

docs/core/extensions/globalization.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,11 @@ How you handle date and time values depends on whether they are displayed in the
128128

129129
Typically, when dates and times are displayed in the user interface, you should use the formatting conventions of the user's culture, which is defined by the <xref:System.Globalization.CultureInfo.CurrentCulture%2A?displayProperty=nameWithType> property and by the <xref:System.Globalization.DateTimeFormatInfo> object returned by the `CultureInfo.CurrentCulture.DateTimeFormat` property. The formatting conventions of the current culture are automatically used when you format a date by using any of these methods:
130130

131-
- The parameterless <xref:System.DateTime.ToString?displayProperty=nameWithType> method
132-
133-
- The <xref:System.DateTime.ToString%28System.String%29?displayProperty=nameWithType> method, which includes a format string
134-
135-
- The parameterless <xref:System.DateTimeOffset.ToString?displayProperty=nameWithType> method
136-
137-
- The <xref:System.DateTimeOffset.ToString%28System.String%29?displayProperty=nameWithType>, which includes a format string
138-
139-
- The [composite formatting](../../standard/base-types/composite-formatting.md) feature, when it is used with dates
131+
- The parameterless <xref:System.DateTime.ToString?displayProperty=nameWithType> method.
132+
- The <xref:System.DateTime.ToString%28System.String%29?displayProperty=nameWithType> method, which includes a format string.
133+
- The parameterless <xref:System.DateTimeOffset.ToString?displayProperty=nameWithType> method.
134+
- The <xref:System.DateTimeOffset.ToString%28System.String%29?displayProperty=nameWithType>, which includes a format string.
135+
- The [composite formatting](../../standard/base-types/composite-formatting.md) feature, when it is used with dates.
140136

141137
The following example displays sunrise and sunset data twice for October 11, 2012. It first sets the current culture to Croatian (Croatia), and then to English (United Kingdom). In each case, the dates and times are displayed in the format that is appropriate for that culture.
142138

docs/csharp/language-reference/tokens/interpolated.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ To identify a string literal as an interpolated string, prepend it with the `$`
2929
The structure of an item with an interpolation expression is as follows:
3030

3131
```csharp
32-
{<interpolationExpression>[,<alignment>][:<formatString>]}
32+
{<interpolationExpression>[,<width>][:<formatString>]}
3333
```
3434

3535
Elements in square brackets are optional. The following table describes each element:
3636

37-
| Element | Description |
38-
|--|--|
37+
| Element | Description |
38+
|---------------------------|-------------|
3939
| `interpolationExpression` | The expression that produces a result to be formatted. When the expression is `null`, the output is the empty string (<xref:System.String.Empty?displayProperty=nameWithType>). |
40-
| `alignment` | The constant expression whose value defines the minimum number of characters in the string representation of the expression result. If positive, the string representation is right-aligned; if negative, left-aligned. For more information, see the [Alignment component](../../../standard/base-types/composite-formatting.md#alignment-component) section of the [Composite formatting](../../../standard/base-types/composite-formatting.md) article. |
41-
| `formatString` | A format string supported by the type of the expression result. For more information, see the [Format string component](../../../standard/base-types/composite-formatting.md#format-string-component) section of the [Composite formatting](../../../standard/base-types/composite-formatting.md) article. |
40+
| `width` | The constant expression whose value defines the minimum number of characters in the string representation of the expression result. If positive, the string representation is right-aligned; if negative, left-aligned. For more information, see the [Width component](../../../standard/base-types/composite-formatting.md#width-component) section of the [Composite formatting](../../../standard/base-types/composite-formatting.md) article. |
41+
| `formatString` | A format string supported by the type of the expression result. For more information, see the [Format string component](../../../standard/base-types/composite-formatting.md#format-string-component) section of the [Composite formatting](../../../standard/base-types/composite-formatting.md) article. |
4242

4343
The following example uses optional formatting components described in the preceding table:
4444

@@ -95,7 +95,7 @@ If you're new to string interpolation, see the [String interpolation in C#](../.
9595
The compiler checks if an interpolated string is assigned to a type that satisfies the [_interpolated string handler pattern_](~/_csharplang/proposals/csharp-10.0/improved-interpolated-strings.md#the-handler-pattern). An _interpolated string handler_ is a type that converts the interpolated string into a result string. When an interpolated string has the type `string`, it's processed by the <xref:System.Runtime.CompilerServices.DefaultInterpolatedStringHandler?displayProperty=fullName>. For the example of a custom interpolated string handler, see the [Write a custom string interpolation handler](../../advanced-topics/performance/interpolated-string-handler.md) tutorial. Use of an interpolated string handler is an advanced scenario, typically required for performance reasons.
9696

9797
> [!NOTE]
98-
> One side effect of interpolated string handlers is that a custom handler, including <xref:System.Runtime.CompilerServices.DefaultInterpolatedStringHandler?displayProperty=nameWithType>, may not evaluate all the interpolation expressions within the interpolated string under all conditions. That means side effects of those expressions may not occur.
98+
> One side effect of interpolated string handlers is that a custom handler, including <xref:System.Runtime.CompilerServices.DefaultInterpolatedStringHandler?displayProperty=nameWithType>, might not evaluate all the interpolation expressions within the interpolated string under all conditions. That means side effects of those expressions might not occur.
9999
100100
If an interpolated string has the type `string`, it's typically transformed into a <xref:System.String.Format%2A?displayProperty=nameWithType> method call. The compiler can replace <xref:System.String.Format%2A?displayProperty=nameWithType> with <xref:System.String.Concat%2A?displayProperty=nameWithType> if the analyzed behavior would be equivalent to concatenation.
101101

docs/csharp/programming-guide/strings/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ A format string is a string whose contents are determined dynamically at run tim
108108

109109
You declare [*Interpolated strings*](../../language-reference/tokens/interpolated.md) with the `$` special character. An interpolated string includes interpolated expressions in braces. If you're new to string interpolation, see the [String interpolation - C# interactive tutorial](../../tutorials/exploration/interpolated-strings.yml) for a quick overview.
110110

111-
Use string interpolation to improve the readability and maintainability of your code. String interpolation achieves the same results as the `String.Format` method, but improves ease of use and inline clarity.
111+
Use string interpolation to improve the readability and maintainability of your code. String interpolation achieves the same results as the `String.Format` method, but is easier to use and improves inline clarity.
112112

113113
:::code language="csharp" source="./snippets/StringInterpolation.cs" id="StringInterpolation":::
114114

@@ -132,7 +132,7 @@ The <xref:System.String.Format%2A?displayProperty=nameWithType> utilizes placeho
132132

133133
:::code language="csharp" source="./snippets/StringInterpolation.cs" id="StringFormat":::
134134

135-
For more information on formatting .NET types, see [Formatting Types in .NET](../../../standard/base-types/formatting-types.md).
135+
For more information, see [Composite formatting in .NET](../../../standard/base-types/composite-formatting.md).
136136

137137
## Substrings
138138

docs/csharp/tutorials/string-interpolation.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Interpolated strings support all the capabilities of the [string composite forma
2525

2626
## How to specify a format string for an interpolation expression
2727

28-
To specify a format string that is supported by the type of the expression result, follow the interpolation expression with a colon (":") and the format string:
28+
To specify a format string that's supported by the type of the expression result, follow the interpolation expression with a colon (":") and the format string:
2929

3030
```csharp
3131
{<interpolationExpression>:<formatString>}
@@ -42,24 +42,24 @@ For more information, see the [Format string component](../../standard/base-type
4242
To specify the minimum field width and the alignment of the formatted expression result, follow the interpolation expression with a comma (",") and the constant expression:
4343

4444
```csharp
45-
{<interpolationExpression>,<alignment>}
45+
{<interpolationExpression>,<width>}
4646
```
4747

48-
If the *alignment* value is positive, the formatted expression result is right-aligned; if negative, it's left-aligned.
48+
If the *width* value is positive, the formatted expression result is right-aligned; if negative, it's left-aligned.
4949

50-
If you need to specify both alignment and a format string, start with the alignment component:
50+
If you need to specify both width and a format string, start with the width component:
5151

5252
```csharp
53-
{<interpolationExpression>,<alignment>:<formatString>}
53+
{<interpolationExpression>,<width>:<formatString>}
5454
```
5555

56-
The following example shows how to specify alignment and uses pipe characters ("|") to delimit text fields:
56+
The following example shows how to specify width and alignment, and uses pipe characters ("|") to delimit text fields:
5757

5858
:::code language="csharp" interactive="try-dotnet-method" source="./snippets/StringInterpolation/Program.cs" id="AlignmentAndFormatString":::
5959

60-
As the example output shows, if the length of the formatted expression result exceeds specified field width, the *alignment* value is ignored.
60+
As the example output shows, if the length of the formatted expression result exceeds specified field width, the *width* value is ignored.
6161

62-
For more information, see the [Alignment component](../../standard/base-types/composite-formatting.md#alignment-component) section of the [Composite formatting](../../standard/base-types/composite-formatting.md) article.
62+
For more information, see the [Width component](../../standard/base-types/composite-formatting.md#width-component) section of the [Composite formatting](../../standard/base-types/composite-formatting.md) article.
6363

6464
## How to use escape sequences in an interpolated string
6565

docs/framework/configure-apps/file-schema/runtime/timespan-legacyformatmode-element.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Determines whether the runtime preserves legacy behavior in formatting operation
1616

1717
[**\<configuration>**](../configuration-element.md)\
1818
&nbsp;&nbsp;[**\<runtime>**](runtime-element.md)\
19-
&nbsp;&nbsp;&nbsp;&nbsp;**\<TimeSpan_LegacyFormatMode>**
19+
&nbsp;&nbsp;&nbsp;&nbsp;**\<TimeSpan_LegacyFormatMode>**
2020

2121
## Syntax
2222

@@ -37,27 +37,27 @@ The following sections describe attributes, child elements, and parent elements.
3737

3838
## enabled Attribute
3939

40-
|Value|Description|
41-
|-----------|-----------------|
42-
|`false`|The runtime does not restore legacy formatting behavior.|
43-
|`true`|The runtime restores legacy formatting behavior.|
40+
| Value | Description |
41+
|---------|----------------------------------------------------------|
42+
| `false` | The runtime does not restore legacy formatting behavior. |
43+
| `true` | The runtime restores legacy formatting behavior. |
4444

4545
### Child Elements
4646

4747
None.
4848

4949
### Parent Elements
5050

51-
|Element|Description|
52-
|-------------|-----------------|
53-
|`configuration`|The root element in every configuration file used by the common language runtime and .NET Framework applications.|
54-
|`runtime`|Contains information about runtime initialization options.|
51+
| Element | Description |
52+
|-----------------|------------------------------------------------------------|
53+
| `configuration` | The root element in every configuration file used by the common language runtime and .NET Framework applications. |
54+
| `runtime` | Contains information about runtime initialization options. |
5555

5656
## Remarks
5757

58-
Starting with the .NET Framework 4, the <xref:System.TimeSpan?displayProperty=nameWithType> structure implements the <xref:System.IFormattable> interface and supports formatting operations with standard and custom format strings. If a parsing method encounters an unsupported format specifier or format string, it throws a <xref:System.FormatException>.
58+
Starting with .NET Framework 4, the <xref:System.TimeSpan?displayProperty=nameWithType> structure implements the <xref:System.IFormattable> interface and supports formatting operations with standard and custom format strings. If a parsing method encounters an unsupported format specifier or format string, it throws a <xref:System.FormatException>.
5959

60-
In previous versions of the .NET Framework, the <xref:System.TimeSpan> structure did not implement <xref:System.IFormattable> and did not support format strings. However, many developers mistakenly assumed that <xref:System.TimeSpan> did support a set of format strings and used them in [composite formatting operations](../../../../standard/base-types/composite-formatting.md) with methods such as <xref:System.String.Format%2A?displayProperty=nameWithType>. Ordinarily, if a type implements <xref:System.IFormattable> and supports format strings, calls to formatting methods with unsupported format strings usually throw a <xref:System.FormatException>. However, because <xref:System.TimeSpan> did not implement <xref:System.IFormattable>, the runtime ignored the format string and instead called the <xref:System.TimeSpan.ToString?displayProperty=nameWithType> method. This means that, although the format strings had no effect on the formatting operation, their presence did not result in a <xref:System.FormatException>.
60+
In previous versions of .NET Framework, the <xref:System.TimeSpan> structure did not implement <xref:System.IFormattable> and did not support format strings. However, many developers mistakenly assumed that <xref:System.TimeSpan> did support a set of format strings and used them in [composite formatting operations](../../../../standard/base-types/composite-formatting.md) with methods such as <xref:System.String.Format%2A?displayProperty=nameWithType>. Ordinarily, if a type implements <xref:System.IFormattable> and supports format strings, calls to formatting methods with unsupported format strings usually throw a <xref:System.FormatException>. However, because <xref:System.TimeSpan> did not implement <xref:System.IFormattable>, the runtime ignored the format string and instead called the <xref:System.TimeSpan.ToString?displayProperty=nameWithType> method. This means that, although the format strings had no effect on the formatting operation, their presence did not result in a <xref:System.FormatException>.
6161

6262
For cases in which legacy code passes a composite formatting method and an invalid format string, and that code cannot be recompiled, you can use the `<TimeSpan_LegacyFormatMode>` element to restore the legacy <xref:System.TimeSpan> behavior. When you set the `enabled` attribute of this element to `true`, the composite formatting method results in a call to <xref:System.TimeSpan.ToString?displayProperty=nameWithType> rather than <xref:System.TimeSpan.ToString%28System.String%2CSystem.IFormatProvider%29?displayProperty=nameWithType>, and a <xref:System.FormatException> is not thrown.
6363

@@ -68,7 +68,7 @@ The following example instantiates a <xref:System.TimeSpan> object and attempts
6868
[!code-csharp[TimeSpan.BreakingChanges#1](../../../../../samples/snippets/csharp/VS_Snippets_CLR/timespan.breakingchanges/cs/legacyformatmode1.cs#1)]
6969
[!code-vb[TimeSpan.BreakingChanges#1](../../../../../samples/snippets/visualbasic/VS_Snippets_CLR/timespan.breakingchanges/vb/legacyformatmode1.vb#1)]
7070

71-
When you run the example on the .NET Framework 3.5 or on an earlier version, it displays the following output:
71+
When you run the example on .NET Framework 3.5 or on an earlier version, it displays the following output:
7272

7373
```console
7474
12:30:45
@@ -80,7 +80,7 @@ This differs markedly from the output if you run the example on the .NET Framewo
8080
Invalid Format
8181
```
8282

83-
However, if you add the following configuration file to the example's directory and then run the example on the .NET Framework 4 or later version, the output is identical to that produced by the example when it is run on .NET Framework 3.5.
83+
However, if you add the following configuration file to the example's directory and then run the example on .NET Framework 4 or a later version, the output is identical to that produced by the example when it is run on .NET Framework 3.5.
8484

8585
```xml
8686
<?xml version ="1.0"?>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
> [!IMPORTANT]
2-
> Instead of calling the **String.Format** method or using [composite format strings](../../../standard/base-types/composite-formatting.md), you can use *interpolated strings* if your language supports them. An interpolated string is a string that contains *interpolated expressions*. Each interpolated expression is resolved with the expression's value and included in the result string when the string is assigned. For more information, see [String interpolation (C# Reference)](../../../csharp/language-reference/tokens/interpolated.md) and [Interpolated Strings (Visual Basic Reference)](../../../visual-basic/programming-guide/language-features/strings/interpolated-strings.md).
2+
> Instead of calling the **String.Format** method or using [composite format strings](../../../standard/base-types/composite-formatting.md), you can use *interpolated strings* if your language supports them. An interpolated string is a string that contains *interpolated expressions*. Each interpolated expression is resolved with the expression's value and included in the result string when the string is assigned. For more information, see [String interpolation (C# Reference)](../../../csharp/language-reference/tokens/interpolated.md) and [Interpolated strings (Visual Basic Reference)](../../../visual-basic/programming-guide/language-features/strings/interpolated-strings.md).

docs/fundamentals/runtime-libraries/system-double.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ The <xref:System.Double> structure and related types provide methods to perform
191191

192192
- **Rounding**. Rounding is often used as a technique for reducing the impact of differences between values caused by problems of floating-point representation and precision. You can round a <xref:System.Double> value by calling the <xref:System.Math.Round%2A?displayProperty=nameWithType> method.
193193

194-
- **Formatting**. You can convert a <xref:System.Double> value to its string representation by calling the <xref:System.Double.ToString%2A> method or by using the composite formatting feature. For information about how format strings control the string representation of floating-point values, see the [Standard Numeric Format Strings](../../standard/base-types/standard-numeric-format-strings.md) and [Custom Numeric Format Strings](../../standard/base-types/custom-numeric-format-strings.md) topics.
194+
- **Formatting**. You can convert a <xref:System.Double> value to its string representation by calling the <xref:System.Double.ToString%2A> method or by using the composite formatting feature. For information about how format strings control the string representation of floating-point values, see [Standard Numeric Format Strings](../../standard/base-types/standard-numeric-format-strings.md) and [Custom Numeric Format Strings](../../standard/base-types/custom-numeric-format-strings.md).
195195

196196
- **Parsing strings**. You can convert the string representation of a floating-point value to a <xref:System.Double> value by calling either the <xref:System.Double.Parse%2A> or <xref:System.Double.TryParse%2A> method. If the parse operation fails, the <xref:System.Double.Parse%2A> method throws an exception, whereas the <xref:System.Double.TryParse%2A> method returns `false`.
197197

0 commit comments

Comments
 (0)