简体   繁体   中英

Can I add a C# class in visual studio as resource so I can add to new projects conveniently?

I create various samples with WPF where I always need to add the same base class for MVVM classes. I always have to go to one of the older projects, find that and add to new project.

Is there a way I can add this to visual studio as reusable component so whenever I need it in a new project, I can just add that? It would just ac# class.

Ideally it would be an option of reusable components in the menu below when I am adding something new to project but if there is any other way would do!

I am using Visual Studio 2019.

在此处输入图片说明

I would just create a class library and share that. Or you could create a project template that has the files you need.

Simply write the class then export as item template... Let you want to add Hello World! class in your every project.

Go to File->Export Template->Item Template... Then select your class to export....

Now whenever you want to add this class to your project click add new item.

You can use Serialization and deserialization of classes

serialization

There is handy plugin: Add New File .

Usage:

Shift + F2 , name new file with .cs extension and class will be created.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM