Ben Bowen's Blog
• Home / Blog •
• About •
• Subscribe •
Categories
All
Software Engineering
Game Design
Personal
Software Engineering Tags
c#
22 posts
multithreading
4 posts
native interop
1 posts
.net
14 posts
oop / api design
1 posts
performance
8 posts
Software Engineering posts tagged with '.NET'
Topics relating to the .NET ecosystem or BCL/FCL libraries.
Complete C# Quick Reference - C# 12
// Summarizing features in C# 12.
Software Engineering
• Monday 27th November 2023
.net
c#
Compared to some previous releases, C# 12 is quite a small, incremental update to the language. Here's the feature summary: You can now define a "primary" constructor for a non-record
class
or
struct
alongside the name of the type (similar to the primary constructor syntax for records):...
Complete C# Quick Reference - C# 11
// Summarizing features in C# 11, including an in-depth look at ref fields and scoping rules.
Software Engineering
• Saturday 19th August 2023
.net
c#
This new feature allows you to specify that a property or field of a class/struct/record
must
be set in an object initializer: So when is this useful? In my opinion, the right time to use this is when: The benefits here are: ...But what if we want to offer an
optional
constructor that helps set the required members with some simple processing? Here's an example:...
Complete C# Quick Reference - C# 10
// Summarizing features in C# 10.
Software Engineering
• Saturday 22nd January 2022
.net
c#
I put this one first as it's been on my personal wishlist for
years
. It's probably the thing I've always missed the most from Java and it always frustrated me that no other C# engineer I ever spoke to seemed to care!...
Complete C# Quick Reference - C# 9
// Summarizing features in C# 9.
Software Engineering
• Wednesday 31st March 2021
.net
c#
This new syntax allows creating properties that can be set using object initialization syntax, but never again: Init-only properties can also have access modifiers applied, just like regular setters: This small feature lets you omit the 'boilerplate' in your program's entry-point (i.e.
Main()
function). Here's a before and after to demonstrate:...
Complete C# Quick Reference - C# 8
// Summarizing features in C# 8.
Software Engineering
• Sunday 28th March 2021
.net
c#
This feature is a large addition to C# that is aimed at helping prevent null reference exceptions at runtime by adding compile-time correctness checking. To enable nullable checking in a project, add
<Nullable>enable</Nullable>
underneath the target framework declaration in the .csproj file: Alternatively, for existing codebases that you want to slowly convert to nullable-checked, compile-time directives can enable/disable this feature in source:...
Complete C# Quick Reference - C# 7
// Summarizing features in C# 7.
Software Engineering
• Thursday 25th March 2021
.net
c#
Tuples are structures that contain a set of two or more related objects. They're useful for handling or returning multiple related values that would not usually be related together in to a class or struct. What if we want to pass a tuple to another function or store it in a container? We can declare a tuple type using a similar syntax:...
Complete C# Quick Reference - C# 5 and C# 6
// Summarizing features in C# 5 and C# 6.
Software Engineering
• Monday 22nd March 2021
.net
c#
This feature is a mainstay of C# and has had such an impact on the industry that it's found its way in to other mainstream languages. There are countless tutorials and books that go deep in to this feature; but this post is just meant as a quick reference guide, so I will only summarize it here....
Complete C# Quick Reference - C# 2, 3 and 4
// Summarizing features in C# 2, C# 3 and C# 4.
Software Engineering
• Friday 19th March 2021
.net
c#
These allow you to specify
null
as a potential value on any struct variable (where
null
would otherwise be invalid):...
C# 8 Concerns - A Followup
// Revisiting the C# 8 Concerns post from two months prior
Software Engineering
• Tuesday 13th November 2018
.net
c#
About two months ago I made a post explaining some concerns I had with two new features in C# 8 (the range/hat operator and default interface methods). If you haven't read that post, I recommend reading it first before coming back here: C# 8 Concerns....
C# 8 Concerns
// Elucidation on some concerns with upcoming new features planned for C# 8
Software Engineering
• Saturday 15th September 2018
.net
c#
In the following post I'm going to talk about two concerns I have with features planned for C# 8. Beforehand though, I just want to point out a couple of things: Also for previous subscribers, I'm sorry for the huge hiatus in blogging. I've been busy with work and all my spare time has been going in to patching my game. That's finally done however so hopefully normal service will be resumed. :)...
Postmortems - Tale of Two Casts
// A deep-dive in to a rare difference between the way the CLR and C# handle a given cast
Software Engineering
• Thursday 1st June 2017
.net
c#
About a year ago I came across a bug that took me a while to get to the bottom of. Look at the following code and see if you can predict the output:...
Three Garbage Examples
// Three examples and explanations of situations that can create unnecessary garbage in .NET4/C#5
Software Engineering
• Friday 8th April 2016
performance
.net
c#
C# (and any language that runs on the CLR) is a garbage-collected language, meaning that objects that have no references to them remaining will have their memory reclaimed at some point in the future. Creating too much garbage (by creating too many ephemeral objects or over-using the
new
keyword) can induce the garbage-collector too frequently, slowing down the entire application....
P/Invoke Tips
// Assorted accrued tips on using P/Invoke in C#
Software Engineering
• Monday 18th January 2016
native interop
performance
.net
c#
Not very many C# programmers will ever need to do much with P/Invoke (Microsoft's technology for interoperation with legacy or native codebases), but for those of us who do, I've amassed a few little tips that aren't always included in the various tutorials found on the 'net....