Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion xml/System.Text/Rune.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ The <xref:System.Text.Rune.EncodeToUtf16*?displayProperty=nameWithType> and <xre

## Rune in .NET vs. other languages

The term "rune" is not defined in the Unicode Standard. The term dates back to [the creation of UTF-8](https://www.cl.cam.ac.uk/~mgk25/ucs/utf-8-history.txt). Rob Pike and Ken Thompson were looking for a term to describe what would eventually become known as a code point. [They settled on the term "rune"](https://twitter.com/rob_pike/status/732353233474064384), and Rob Pike's later influence over the Go programming language helped popularize the term.
The term "rune" is not defined in the Unicode Standard. The term dates back to [the creation of UTF-8](https://www.cl.cam.ac.uk/~mgk25/ucs/utf-8-history.txt). Rob Pike and Ken Thompson were looking for a term to describe what would eventually become known as a code point. They settled on the term "rune", and Rob Pike's later influence over the Go programming language helped popularize the term.

However, the .NET `Rune` type is not the equivalent of the Go `rune` type. In Go, the `rune` type is an [alias for `int32`](https://blog.golang.org/strings). A Go rune is intended to represent a Unicode code point, but it can be any 32-bit value, including surrogate code points and values that are not legal Unicode code points.

Expand Down
3 changes: 1 addition & 2 deletions xml/System/Exception.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,9 @@ In addition, do not throw an exception when a return code is sufficient; do not
In many cases, an exception handler simply wants to pass the exception on to the caller. This most often occurs in:

- A class library that in turn wraps calls to methods in the .NET class library or other class libraries.

- An application or library that encounters a fatal exception. The exception handler can log the exception and then re-throw the exception.

The recommended way to re-throw an exception is to simply use the [throw](/dotnet/csharp/language-reference/keywords/throw) statement in C#, the [reraise](/dotnet/fsharp/language-reference/exception-handling/the-raise-function.md#reraising-an-exception) function in F#, and the [Throw](/dotnet/visual-basic/language-reference/statements/throw-statement) statement in Visual Basic without including an expression. This ensures that all call stack information is preserved when the exception is propagated to the caller. The following example illustrates this. A string extension method, `FindOccurrences`, wraps one or more calls to <xref:System.String.IndexOf(System.String,System.Int32)?displayProperty=nameWithType> without validating its arguments beforehand.
The recommended way to re-throw an exception is to simply use the [throw](/dotnet/csharp/language-reference/keywords/throw) statement in C#, the [reraise](/dotnet/fsharp/language-reference/exception-handling/the-raise-function#reraising-an-exception) function in F#, and the [Throw](/dotnet/visual-basic/language-reference/statements/throw-statement) statement in Visual Basic without including an expression. This ensures that all call stack information is preserved when the exception is propagated to the caller. The following example illustrates this. A string extension method, `FindOccurrences`, wraps one or more calls to <xref:System.String.IndexOf(System.String,System.Int32)?displayProperty=nameWithType> without validating its arguments beforehand.

:::code language="csharp" source="~/snippets/csharp/System/Exception/Overview/rethrow1.cs" id="Snippet6":::
:::code language="fsharp" source="~/snippets/fsharp/System/Exception/Overview/rethrow1.fs" id="Snippet6":::
Expand Down
2 changes: 1 addition & 1 deletion xml/System/IDisposable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ For more information about the `try`/`finally` pattern, see [try-finally (C#)](/

## Implement IDisposable

You should implement <xref:System.IDisposable> if your type uses unmanaged resources directly or if you wish to use disposable resources yourself. The consumers of your type can call your <xref:System.IDisposable.Dispose*?displayProperty=nameWithType> implementation to free resources when the instance is no longer needed. To handle cases in which they fail to call <xref:System.IDisposable.Dispose*>, you should either use a class derived from <xref:System.Runtime.InteropServices.SafeHandle> to wrap the unmanaged resources, or you should override the <xref:System.Object.Finalize*?displayProperty=nameWithType> method for a reference type. In either case, you use the <xref:System.IDisposable.Dispose*> method to perform whatever cleanup is necessary after using the unmanaged resources, such as freeing, releasing, or resetting the unmanaged resources. For more information about implementing <xref:System.IDisposable.Dispose*?displayProperty=nameWithType>, see [the Dispose(bool) method overload](/dotnet/standard/garbage-collection/implementing-dispose.md#the-disposebool-method-overload).
You should implement <xref:System.IDisposable> if your type uses unmanaged resources directly or if you wish to use disposable resources yourself. The consumers of your type can call your <xref:System.IDisposable.Dispose*?displayProperty=nameWithType> implementation to free resources when the instance is no longer needed. To handle cases in which they fail to call <xref:System.IDisposable.Dispose*>, you should either use a class derived from <xref:System.Runtime.InteropServices.SafeHandle> to wrap the unmanaged resources, or you should override the <xref:System.Object.Finalize*?displayProperty=nameWithType> method for a reference type. In either case, you use the <xref:System.IDisposable.Dispose*> method to perform whatever cleanup is necessary after using the unmanaged resources, such as freeing, releasing, or resetting the unmanaged resources. For more information about implementing <xref:System.IDisposable.Dispose*?displayProperty=nameWithType>, see [the Dispose(bool) method overload](/dotnet/standard/garbage-collection/implementing-dispose#the-disposebool-method-overload).

> [!IMPORTANT]
> If you're defining a base class that uses unmanaged resources and that either has, or is likely to have, subclasses that should be disposed, you should implement the <xref:System.IDisposable.Dispose*?displayProperty=nameWithType> method and provide a second overload of `Dispose`, as discussed in the next section.
Expand Down
7 changes: 2 additions & 5 deletions xml/System/String.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5771,7 +5771,7 @@ A format item has this syntax:
{index[,width][:formatString]}
```

Brackets denote optional elements. The opening and closing braces are required. (To include a literal opening or closing brace in the format string, see the [Escaping Braces](/dotnet/standard/base-types/composite-formatting.md#escaping-braces) section in the [Composite Formatting](/dotnet/standard/base-types/composite-formatting) article.)
Brackets denote optional elements. The opening and closing braces are required. (To include a literal opening or closing brace in the format string, see the [Escaping Braces](/dotnet/standard/base-types/composite-formatting#escaping-braces) section in the [Composite Formatting](/dotnet/standard/base-types/composite-formatting) article.)

For example, a format item to format a currency value might appear like this:

Expand Down Expand Up @@ -5815,16 +5815,13 @@ The following example uses the `width` and `formatString` arguments to produce f
Format items are processed sequentially from the beginning of the string. Each format item has an index that corresponds to an object in the method's argument list. The <xref:System.String.Format*> method retrieves the argument and derives its string representation as follows:

- If the argument is `null`, the method inserts <xref:System.String.Empty?displayProperty=nameWithType> into the result string. You don't have to be concerned with handling a <xref:System.NullReferenceException> for null arguments.

- If you call the <xref:System.String.Format(System.IFormatProvider,System.String,System.Object%5B%5D)> overload and the `provider` object's <xref:System.IFormatProvider.GetFormat*?displayProperty=nameWithType> implementation returns a non-null <xref:System.ICustomFormatter> implementation, the argument is passed to its <xref:System.ICustomFormatter.Format(System.String,System.Object,System.IFormatProvider)?displayProperty=nameWithType> method. If the format item includes a `formatString` argument, it is passed as the first argument to the method. If the <xref:System.ICustomFormatter> implementation is available and produces a non-null string, that string is returned as the string representation of the argument; otherwise, the next step executes.

- If the argument implements the <xref:System.IFormattable> interface, its <xref:System.IFormattable.ToString*?displayProperty=nameWithType> implementation is called.

- The argument's parameterless `ToString` method, which either overrides or inherits from a base class implementation, is called.

For an example that intercepts calls to the <xref:System.ICustomFormatter.Format*?displayProperty=nameWithType> method and allows you to see what information the <xref:System.String.Format*> method passes to a formatting method for each format item in a composite format string, see [Example: An intercept provider and Roman numeral formatter](#example-an-intercept-provider-and-roman-numeral-formatter).

For more information, see [Processing order](/dotnet/standard/base-types/composite-formatting.md#processing-order).
For more information, see [Processing order](/dotnet/standard/base-types/composite-formatting#processing-order).

## Format items that have the same index

Expand Down
Loading