-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example for optional attr (#9355)
* Add example for optional attr * Fix up space issues Co-authored-by: Genevieve Warren <[email protected]>
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
snippets/csharp/System.Runtime.InteropServices/OptionalAttribute/Overview/Project.csproj
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,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Library</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
18 changes: 18 additions & 0 deletions
18
snippets/csharp/System.Runtime.InteropServices/OptionalAttribute/Overview/sample.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,18 @@ | ||
//<snippet1> | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
public class Program | ||
{ | ||
public static void MethodWithOptionalAttribute([Optional] string str) | ||
{ | ||
Console.WriteLine($"str is null: {str == null}"); | ||
} | ||
|
||
public static void Main() | ||
{ | ||
MethodWithOptionalAttribute(); // str is null: True | ||
MethodWithOptionalAttribute("abc"); // str is null: False | ||
} | ||
} | ||
//</snippet1> |
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