If you have prettier as the default formatter as I do, you should do this:
-
Open your vscode settings with these shortcut:
ctrl + ,, or
-
Then click to “open settings (JSON)”:

-
This is where you should paste the below snippet.
This is my config:
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[csharp]": {
"editor.defaultFormatter": "ms-dotnettools.csharp"
}
}
For you to apply this configuration you need c# extension.