How to Use Enums in CSharp – Understanding the Basics
Looking to enhance your C# coding skills? Learn how to use enums in Csharp with this beginner guide, including best practices, limitations, and examples.
Find examples of code, tutorials, and walkthroughs! When discussing programming and software engineering topics, examples are critical!
Looking to enhance your C# coding skills? Learn how to use enums in Csharp with this beginner guide, including best practices, limitations, and examples.
If you want to see examples of the builder pattern in C#, dive into this article. We'll explore how the builder pattern in C# works with code examples!
If you're familiar with Autofac and module registration but want to make things easier, automatic module discovery might be for you! Let's see how it works!
In C#, how can we balance asynchrony and laziness? Is there such a thing as async lazy? Let's explore our options built into dotnet!
The facade pattern is useful for hiding complexity by moving dependencies behind an API. Let's dive into the facade design pattern in C# in this article!
This article is not set out to try and persuade you, the reader, that either using an iterator or materialized collection will universally solve your problems. Both iterator and materialized collection usage can be used to solve the scenarios that we'll be looking at, but both will come with a different set of pros and cons that we can further explore. The purpose of this article is to highlight scenarios based on real world experiences where either an iterator or materialized collection was being misunderstood, misused, and ultimately leading to a pile of headaches. As you read this article, if you find yourself saying "Well, sure, but they should have..." you're probably right. The problem is fundamentally not the usage of an iterator or the materialized collection, but not understanding how to consume them effectively. So I hope that when…
If you're newer to C# or programming in general, you may have used an iterator and not even realized it. Iterators can be a performant and effective tool that we have access to as .NET developers that allow us to traverse collections of data. Because one of the requirements of an iterator is that it must implement the IEnumerable interface, the results of an iterator can only be enumerated over. For example, you could use the results of an iterator in a foreach loop but you could not directly index into the iterator results (like you could an array) without some additional steps. Another requirement of iterators is that they use a special keyword called "yield" so that they can yield and return the individual elements that are to be provided to the caller of the iterator. In a nutshell,…
New to C# and looking to understand more about the IEnumerable interface? Check out this article for a crash course on getting started with C# IEnumerable!
Working with strings is probably one of the earliest things we get to do as C# developers. In fact, if you consider that most of us start with the "Hello, World!" example, you're being exposed to the string type right away. But as you continue to use strings, you'll quickly find that you want to work with strings that span multiple lines and how we define multiline strings might be a tricky topic for beginners. No sweat! In this article, we'll look at some simple code examples that demonstrate how to define multiline strings. I'll also link over to GitHub where you can see this code committed and pushed up to a public repository. Finally, the last example contains a special bonus that I think you'll like (even if it's a slightly more advanced topic). Read until the end! What's…
In C# 9.0 we received access to a great quality of life type called the record. You can read more about that from Microsoft here. Record types allowed us as dotnet programmers to skip a lot of boiler plate code, thereby saving us time and making code more readable. Wins all around! Before record types, we might have simple data transfer objects (called DTOs) that would look something like the following: public sealed class MyData { public MyData( string value1, int value2) { Value1 = value1; Value2 = value2; } publc string Value1 { get; } publc int Value2 { get; } } And for a simple class with two properties... I think we can all agree that the verbosity here is just over the top. With the record type that we were given access to, we can now write…