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
var connection = new signalR.HubConnectionBuilder() | |
.withUrl("/chatHub") | |
.build(); | |
connection.serverTimeoutInMilliseconds = 60000; | |
connection.keepAliveIntervalInMilliseconds = 30000; |
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
await foreach (var item in GetItemsAsync()) | |
{ | |
Console.WriteLine(item.value); | |
} |
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
var result = obj switch | |
{ | |
> 0 => "Positive", | |
< 0 => "Negative", | |
_ => "Zero" | |
}; |
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
var result = obj switch | |
{ | |
int i when i > 0 => "Positive", | |
int i when i < 0 => "Negative", | |
_ => "Zero" | |
}; |
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
foreach (var blog in blogs) | |
{ | |
if (context.Entry(blog).Collection(e => e.Posts).IsLoaded) | |
{ | |
Console.WriteLine($" Posts for blog '{blog.Name}' are loaded."); | |
} | |
} |
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
var blogs = await context.Blogs.AsNoTracking().ToListAsync(); | |
if (int.TryParse(ReadLine(), out var blogId)) | |
{ | |
Console.WriteLine("Posts:"); | |
foreach (var post in blogs[blogId - 1].Posts) | |
{ | |
Console.WriteLine($" {post.Title}"); | |
} | |
} |
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
AppContext.SetData("GCHeapHardLimit", (ulong)100 * 1024 * 1024); | |
MethodInfo refreshMemoryLimitMethod = typeof(GC).GetMethod( | |
"_RefreshMemoryLimit", BindingFlags.NonPublic | BindingFlags.Static); | |
refreshMemoryLimitMethod.Invoke(null, Array<object>.Empty); |
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
// Hashing example | |
if (SHA3_256.IsSupported) | |
{ | |
byte[] hash = SHA3_256.HashData(dataToHash); | |
} | |
else | |
{ | |
// ... | |
} |
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
YourType[] trainingData = LoadTrainingData(); | |
Random.Shared.Shuffle(trainingData); |
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
private static ReadOnlySpan<Button> s_allButtons = new[] | |
{ | |
Button.Red, | |
Button.Green, | |
Button.Blue, | |
Button.Yellow, | |
}; | |
// ... |