All posts with Tag struct

Preview image blogpost

Mutable value types are evil! Sort of...

You might have heard that mutable value types are evil. But why is that and why does the .NET framework use them then? Are they really that evil?

Let's have a look at a few examples and have a look what is going on!

Read the whole article

Preview image blogpost

Low-level struct improvements in C# 11

C# 11 brings some major improvements for structs. You remember Span<T>, which you couldn't create?

Now you can. C# 11 allows ref fields in a struct. Why this is a cool thing and what you can do with it, you will see in a minute.

Read the whole article

Preview image blogpost

default(MyStruct) vs new MyStruct() - what is the difference?

There are multiple ways to create a new struct, either via var myStruct = default(MyStruct) or via var myStruct = new MyStruct(); . Are there any differences?

Read the whole article

struct vs readonly struct vs ref struct vs record struct

C# knows struct since its down of time. But there are also recent additions like readonly struct, record struct and ref struct.

This article will show what are the differences between those 4.

Read the whole article

struct Performance

Let's have a small look into structs and how they work when using Equals and GetHashCode. Plus have a brief look into a new C# 10 feature: readonly record struct.

Read the whole article

An error has occurred. This application may no longer respond until reloaded. Reload x