This site runs best with JavaScript enabled.Spencer Schneidenbach

Iterators in C#, IEnumerable<T>, and IAsyncEnumerable<T>

TL;DR – Iterators - the thing that allows you to use the yield keyword in functions that return IEnumerable<T> - do magic under the hood and are significantly different from non-iterator code that returns IEnumerable<T> . In addition , up until recently iterators did not support async…

Read Article →

A Brief Comparison Between Newtonsoft.Json and System.Text.Json

TL;DR – System.Text.Json is a new JSON library for .NET with different design goals from its predecessor, Newtonsoft.Json. If you’re already using Newtonsoft.Json in an existing project, you likely don’t need to switch. If you absolutely need high JSON serialization/deserialization performance…

Read Article →

Essential .NET, C#, VB.NET, and Web Dev Tools and Frameworks - Updated for 2019

Updated for 2019 - but this time I ended up removing a bunch of stuff, like Angular. New items are bolded. Here is my (mostly) comprehensive list of tools I use for development, either at home or work.  It’s like Scott Hanselman’s , but focused almost purely on development, with a couple of extras…

Read Article →

Paging in ASP.NET Web API

Paging is a useful concept in any API.  Here’s an example of one that I use pretty frequently when making APIs in ASP.NET Web API. You can download an example project (complete with unit tests!) here:  https://github.com/schneidenbach/AspNetPagingExample The steps we’re going to take to complete…

Read Article →

Emojis and String.Length in C#

Are you using String.Length to compute the length of a string that might include emojis? If you compute String.Length for such a string, you may not get back exactly what you expect: This will write 12 to the screen. What were YOU expecting? This happens because C# strings are UTF-16 by default…

Read Article →

Why does the Nameof operator in VB.NET return the member name with the wrong case?

nameof is one of my favorite operators in C# 6 – it’s a little thing that makes life a little easier.  I use it a lot in Entity Framework 6 with the ForeignKey attribute  and when throwing ArgumentExceptions so that I don’t have to have magic strings everywhere. I discovered some interesting…

Read Article →

RESTful API Best Practices and Common Pitfalls

As a person who spends his day integrating systems, I’ve found that at least half of the APIs I use radically differ from REST semantics, make changes too often and too quickly, don’t validate enough, and/or don’t have proper documentation. There are tons of resources for making good RESTful APIs…

Read Article →