-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update attributes language reference
- Loading branch information
1 parent
28be8eb
commit f8a35e5
Showing
4 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
docs/csharp/language-reference/attributes/snippets/OrpaSnippets.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace attributes; | ||
public class OverloadExample | ||
{ | ||
|
||
public static void OrpaExample() | ||
{ | ||
// <SnippetOrpaExample> | ||
var d = new OverloadExample(); | ||
int[] arr = [1, 2, 3]; | ||
d.M(1, 2, 3, 4); // Prints "Span" | ||
d.M(arr); // Prints "Span" when PriorityAttribute is applied | ||
d.M([1, 2, 3, 4]); // Prints "Span" | ||
d.M(1, 2, 3, 4); // Prints "Span" | ||
// </SnippetOrpaExample> | ||
} | ||
|
||
// <SnippetOverloadExample> | ||
[OverloadResolutionPriority(1)] | ||
public void M(params ReadOnlySpan<int> s) => Console.WriteLine("Span"); | ||
// Default overload resolution priority of 0 | ||
public void M(params int[] a) => Console.WriteLine("Array"); | ||
// </SnippetOverloadExample> | ||
} |
3 changes: 3 additions & 0 deletions
3
docs/csharp/language-reference/attributes/snippets/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters