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!
Author And Source
この問題について(How to use SharedProject with UWP application in Visual Studio), 我々は、より多くの情報をここで見つけました https://qiita.com/phanithken/items/c64bdc29432f22dec466著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .