C Sharp

!csharp

@programming.dev
Create post
Writing “string.IsNullOrEmpty” using pattern matching and comparing the resulting code

Writing “string.IsNullOrEmpty” using pattern matching and comparing the resulting code

Open link in next tab

Writing “string.IsNullOrEmpty” using pattern matching and comparing the resulting code | tabs ↹ over ␣ ␣ ␣ spaces by Jiří {x2} Činčura

https://www.tabsoverspaces.com/233939-writing-string-isnullorempty-using-pattern-matching-and-comparing-the-resulting-code

Refactor your code with C# collection expressions - .NET Blog

Refactor your code with C# collection expressions - .NET Blog

Open link in next tab

Refactor your code with C# collection expressions - .NET Blog

https://devblogs.microsoft.com/dotnet/refactor-your-code-with-collection-expressions/

Explore various C# 12 refactoring scenarios for a variety of target types using collection expressions and collection initializers.

Beyond Boundaries - Networking Programming with C# 12 and .NET 8 Book Home

Beyond Boundaries - Networking Programming with C# 12 and .NET 8 Book Home

Open link in next tab

Beyond Boundaries - Networking Programming with C# 12 and .NET 8 Book Home

https://csharp-networking.com/

Have questions or feedback about the book? My email is cwoodruff@live.com.

Adventures serializing absolutely everything in C#

Adventures serializing absolutely everything in C#

Open link in next tab

Adventures serializing absolutely everything in C# – isadora

https://isadorasophia.com/articles/serialization/

![](/images/html/me.png)

C# workbook recommendations?

C# workbook recommendations?

Hi all. I've been wanting to get into programming for a while now, specifically C#. However, I am not good at self-study or self-guided learning. Are there any good textbooks/workbooks that you'd recommend to learners of C# as a first programming language? I have some experience with coding, but not much more than simple command-line calculators (due to aforementioned lack of self-teaching skills).

To clarify, I'm looking for a straightforward textbook where I could read a chapter and do the associated "exercises" (for lack of a better word)

Opinions needed: Best way to develop NuGet packages

Opinions needed: Best way to develop NuGet packages

My favorite way to develop applications is microservices, or at least smaller services that can separate concerns a little bit. In our current application, there is an API we've created with an OAS document and an auto-generated .NET SDK based on the document. We then have a web console that makes calls to the backend API using the SDK and, ideally, customers would also use the SDK.

So my question to everyone is: what is the best "flow" to develop a NuGet package?

Currently, we have pipelines which publish the NuGet package of the SDK to our internal NuGet repository on every commit within a merge request. We have a manually incrementing semver with an additional build number tacked on (for example 1.2.3+abc123).

Now this works pretty well, but we often run into problems where a tester's NuGet doesn't pull down the latest version based on the build number if it detects it has the proper semver number. For example, if we create 1.2.3+abc456 NuGet won't pull down this version as long as it has the original 1.2.3+abc123 in its .nuget/packages directory. Testers and developers have to manually delete the version from the packages directory and do a fresh restore.

So, is there a better way to do build numbers? Or should I be deleting the NuGet package from the private repository every time (doesn't sound ideal...)?

The other part of this question is what is the best way to develop and test NuGet packages locally?

My current flow is a PowerShell script which will create the new .nupkg file, publish it to a local/filesystem NuGet directory with some random semver number (i.e., 9.9.9), update the .csproj with the version (temporarily), and then do a fresh dotnet restore on the target project. However, this can be cumbersome and feels like something that should be built into the dotnet command. Am I missing something, or is this really the best way to develop locally?

Fastest Way to Get the First N Characters of a String in C# - Code Maze

Fastest Way to Get the First N Characters of a String in C# - Code Maze

Open link in next tab

Fastest Way to Get the First N Characters of a String in C# - Code Maze

https://code-maze.com/csharp-fastest-way-to-get-the-first-n-characters-of-a-string/

In this article, we will perform benchmark tests to determine the fastest way to get the first N characters of a string in C#.

How to Use StringPool to Reduce String Allocations in C# - Code Maze

How to Use StringPool to Reduce String Allocations in C# - Code Maze

Open link in next tab

How to Use StringPool to Reduce String Allocations in C# - Code Maze

https://code-maze.com/csharp-use-stringpool-to-reduce-string-allocations/

This article explores how to use StringPool to reduce string allocations in C#, including sample code and a benchmark section.

async void Methods In C# – The Dangers That You Need to Know

async void Methods In C# – The Dangers That You Need to Know

Open link in next tab

async void Methods In C# – The Dangers That You Need to Know

https://www.devleader.ca/2024/03/07/async-void-methods-in-c-the-dangers-that-you-need-to-know/

Learn why async void methods in C# can be dangerous with clear code examples. A perfect for beginner software engineers wanting to understand the risks.

How to Implement the Strategy Pattern in C# for Improved Code Flexibility

How to Implement the Strategy Pattern in C# for Improved Code Flexibility

Open link in next tab

How to Implement the Strategy Pattern in C# for Improved Code Flexibility

https://www.devleader.ca/2023/11/22/how-to-implement-the-strategy-pattern-in-c-for-improved-code-flexibility/

Learn how the Strategy Pattern in C# provides flexibility! Let's explore an example of the strategy pattern in C# along with the pros and cons of using it!