The 4 'secret' C# keywords that you shouldn't use

preview_player
Показать описание

Hello everybody I'm Nick and in this video I am going to talk about the 4 secret or hidden keywords in C#. Those keywords are not part of the spec and there is no official documentation by Microsoft about them at all. In this video I will show you what they do and how you could use them.

Timestamps
Intro - 0:00
__makeref - 0:43
__refvalue & __reftype - 6:26
__arglist - 7:50

Don't forget to comment, like and subscribe :)

Social Media:

#dotnet #secretkeywords #csharp
Рекомендации по теме
Комментарии
Автор

So __arglist is kind of like the 'params' keyword, but with pointer shenanigans?

lordshoe
Автор

Are items in arrays always stored exactly adjacent, or is the compiler allowed to add some padding in between? For example if there's a struct of 7 bytes where one member is an int, are there cpu architectures where the int must be at an address that's a multiple of 4?

abeker
Автор

Small thing, you have a typo in the timestamps. You wrote __rettype instead of __reftype.
Great job on the video as always!

bartekm
Автор

05:10 sizeOfB is using sizeof(SomeStructA). Very interesting keywords.

diego_samano
Автор

Hi is there any difference in Dot net programming on AMD Ryzen and Intel processor in terms of performance and compatibility? Or both works same with dotnet ?

arunkumarsingh
Автор

You type in "C# hidden keywords" in Google and I'm the first search result! WOO.

When I was contracting at MS a long, long time ago, I stumbled across an obscure MSDN example that had __argslist in it, I believe. That's how I found out about them. I believe I even had to ping the dev that wrote the example, and there was 0 way that should have slipped through into documentation.

ZachLayne-di
Автор

Can't we use 'fixed' keyword to pin the array?

mastermati
Автор

In asp dotnet
AsyncLocal<T> is used to hold the context within the HttpContextAccessor
Is there a way to provide the same functionality of AsyncLocal<T> but through the DI?
It's kind of scoped object but without a real DI scope!

amrosamy
Автор

Isnt most of this superseded by the unmanaged generic constraint in newer c# ?

Khitiara_
Автор

I heard that __arglist also doesn't produce GC Allocs, which may be nice if you're super concerned

saniel