How to handle cancellation of x number of running background tasks.
SharpLab is a .NET code playground that shows intermediate steps and results of code compilation. Some language features are thin wrappers on top of other features — e.g.
try/finally. SharpLab allows you to see the code as compiler sees it, and get a better understanding of .NET languages.
Recent versions include experimental support for running code, with some limitations.
Online tool: SharpLab
Sometimes you need to implement some sort of retry logic if an error occurs in a c# program.
Existing libraries for retry and fault handling:
Read more about the related Circuit Breaker pattern:
Circuit Breaker Pattern
Error handling and policies in general:
In general these interfaces and methods are good to implement when working with comparing objects of the same type in C#:
System.IEquatable<T> – strongly typed implementation
IComparable<T> – strongly typed implementation
An override of Object.Equals(Object).
An override of Object.GetHashCode().
An override of Object.ToString() is usually a good idea.
Operator overloads for operator == and operator !=.
General rule of GetHashCode():
If two objects is equal then their hashvalues should be the same.
If Equals == true then
x.GetHashCode() == y.GetHashCode()
GetHashCode() is frequently used by collections like Dictionary<Key, Value> and HashSet<T>
Guidelines for Overloading Equals() and Operator == (C# Programming Guide)
- How to best implement Equals for custom types?
- Implement value objects
- C# – Always valid value objects
- What is the best algorithm for overriding GetHashCode?
Regular expression tester with syntax highlighting, PHP / PCRE & JS Support, contextual help, cheat sheet, reference, and searchable community patterns.
Active Directory security groups are used to grant users’ permissions to various domain services and resources. Therefore, to understand what permissions are assigned to a specific user in the AD domain, it is enough to look at the groups in which the user account is a member.
I’ve long blogged about my love of setting up a nice terminal, getting the prompt just right, setting my colors, fonts, glyphs, and more. Here’s some of my posts.
I want to take a moment to update my pretty prompt post with a little more detail and a more complex PowerShell $PROFILE, due to some changes in Oh My Posh, PowerShell, and the Windows Terminal. I doubt that this post is perfect and I’m sure there’s stuff here that is a little extra. But I like it, and this post will serve as my “setting up a new machine” post until I get around to writing a script to do all this for me in one line.
I love my prompt.
Pre made script to make it look like Scott Hanselmans example prompt:
You can add an EditorConfig file to your project or codebase to enforce consistent coding styles for everyone that works in the codebase. EditorConfig settings take precedence over global Visual Studio text editor settings. This means that you can tailor each codebase to use text editor settings that are specific to that project. You can still set your own personal editor preferences in the Visual Studio Options dialog box. Those settings apply whenever you’re working in a codebase without an .editorconfig file, or when the .editorconfig file doesn’t override a particular setting. An example of such a preference is indent style—tabs or spaces.