How to use SharedProject with UWP application in Visual Studio
Introduction
In Visual Studio we can create Shared Project and use it later in any UWP project. This is one of a good way we can re-use some C# codes in multiple UWP project.
What is Shared Project?
Shared Project is a great way of sharing common code across multiple applications. It will be added as part of the application and compiled along with it. So we can easily re-use the some identical C# code with multiple application. It can easily be done using the Add Reference feature in UWP application solution explorer.
Create a Shared Project
From Visual Studio Click File -> New Project Navigate to Template -> Visual C#
From there we will find "Shared Project"C# template
Once we create a new project, It will create a Shared Project in the Solution Explorer like below
After that we will add some code to the Shared Project we just create
So we added class Student into it
Use Shared Project in UWP application
From the existing UWP project right click on the Solution Explorer -> Add -> Existing Project and then browse for the Shared Project that we just created.
After that from the project reference tree right click on the Project Name -> Add -> Reference
And from the Reference Manager Choose Shared Project and Check the Project we just created. If there is nothing there, we can go and browse for it.
Now that our Shared Project code is ready to used.
From our MainPage.cs we import the Student class from the Shared Project
P.S: SharedProject is my shared project namespace. It may be vary.
using SharedProject;
namespace DemoUWP {
public sealed partial class MainPage: Page {
public MainPage() {
Student student = new Student();
}
}
}
The code above is the demonstration of how we can use the code. That's all for this article. Thank you!
Reference
이 문제에 관하여(How to use SharedProject with UWP application in Visual Studio), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/phanithken/items/c64bdc29432f22dec466텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)