Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set interface to public by default in C#

Is there any way for Visual Studio to create my interface 'public'? For example, right click on folder -> create new item -> code -> interface.

Whenever the file is created there are no access modifiers.

interface IMyInterface 
{

}

Is there any way to default it to make it public?

public interface IMyInterface
{

}

I'm always forgetting to manually change them to public (when they need to be).

like image 417
Anonymous Avatar asked Jan 05 '13 12:01

Anonymous


1 Answers

Open your project with the public IMyInterface interface shown above.

Go to File > Export Template.

Follow the steps (make sure you choose item template rather than Project template) and save it under a name of your choice.

When you restart visual studio and have a project open it will be available from the add item dialog. You will be able to set the name of the interface from the dialog just like you can with the other items.

Note that this does not overwrite the default interface template installed with Visual Studio so you can still just as easily make a private interface when required.

like image 190
Benjamin Gale Avatar answered Sep 26 '22 01:09

Benjamin Gale