'Default access modifier for new C#-classes in Visual Studio 2022
When I generate a new class in Visual Studio (C#), I would like to have the default access modifier changed from "internal" to "public". E.g.:
public class Animal
{
}
instead of:
internal class Animal
{
}
Is there a setting in Visual Studio (2022) where the default access modifier for new classes can be set?
Solution 1:[1]
I tried same for Visual Studio Community 2022 (V 17.1.0)
Open Class.cs at
%ProgramFiles%\Microsoft Visual Studio\2022\Community\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class\Class.cs
The Class.cs file location depends on your installation directory.
Existing class code
class $safeitemrootname$
{
}
Add public keyword
public class $safeitemrootname$
{
}
and Save the file. It's working on my machine.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rohit Jadhav |
