Start Debugging

Tag: csharp

72 posts · Page 5 of 8

2023-09-11 csharpdotnetdotnet-8
.NET 8 – Mark JsonSerializerOptions as readonly
Learn how to mark JsonSerializerOptions instances as read-only in .NET 8 using MakeReadOnly, and how to check the IsReadOnly property.
2023-09-07 csharpdotnetdotnet-8
.NET 8 – Serialization of Half, Int128, and UInt128
System.Text.Json in .NET 8 adds built-in serialization support for the Half, Int128, and UInt128 numeric types.
2023-09-06 csharpdotnetdotnet-8
.NET 8 – Memory<byte> is serialized as base64
Starting with .NET 8, both Memory<byte> and ReadOnlyMemory<byte> are serialized as Base64 strings, while other types like Memory<int> remain JSON arrays.
2023-09-05 csharpdotnetdotnet-8
.NET 8 – Include non-public members in JSON serialization
Learn how to include private, protected, and internal properties in JSON serialization in .NET 8 using the JsonInclude attribute.
2023-08-31 csharp
C# 12 – Inline arrays
Inline arrays enable you to create an array of fixed size in a struct type. Such a struct, with an inline buffer, should provide performance comparable to an unsafe fixed size buffer. Inline arrays are mostly to be used by the runtime team and some library authors to improve performance in certain scenarios. You likely…
2023-08-30 csharp
C# 12 – Collection expressions
C# 12 introduces a new simplified syntax for creating arrays. It looks like this: It’s important to note that the array type needs to be specified explicitly, so you cannot use var for declaring the variable. Similarly, if you wanted to create a Span<int>, you can do: Multi-dimensional arrays The advantages of this terse syntax…
2023-08-11 csharpdotnet
C# How to wait for a process to end?
You can use the WaitForExit method to wait for the process to complete. Your code will wait synchronously for the process to finish, then it will resume execution. Let’s look at an example: The code above will start a new cmd.exe process, and execute the timeout 5 command. The process.WaitForExit() call will force your program…
2023-08-06 csharp
C# 12 – Alias any type
The using alias directive has been relaxed in C# 12 to allow aliasing any sort of type, not just named types. This means that you can now alias tuples, pointers, array types, generic types, etc. So instead of using the full structural form of a tuple, you can now alias it with a short descriptive…
2023-08-05 csharp
Is there a C# With…End With statement equivalent?
The With…End With statement in VB allows you to execute a series of statements that repeatedly refer to a single object. Thus the statements can use a simplified syntax for accessing members of the object. For example: Is there a C# syntax equivalent? No. There is not. The closest thing to it would be the…
2023-07-30 csharp
C# 12 – Primary constructors
Starting from C# 12, it is possible to define a primary constructor within classes and structs. The parameters are placed in parentheses right after the type name. The parameters of a primary constructor have a broad scope. They can be utilized to initialize properties or fields, serve as variables in methods or local functions, and…
Prev Next