Blazor offers a way to write C# code directly into a .Razor component. It’s very convenient though as many like to have the C# code in a separate class (a partial class) of the .razor page. With the 2022 version of Visual Studio, you can create the code behind in one click!
The function is just at the level of the icon of the bulb which will propose you that :
My VS 2022 doesnt have this! 🙁