- .NET Standard 2.0 Cookbook
- Fiqri Ismail
- 335字
- 2021-06-25 22:11:36
How to do it...
- Open Visual Studio 2017.
- Now open the solution from the previous recipe. Click File | Open | Open Project/Solution, or press Ctrl + Shift + O, and select the Chapter2.Primitives solution.
- Now click on the Chapter2.Library solution label. Click File | Add | New Project.
- In the Add New Project template dialog box, expand the Visual C# node in the left-hand pane.
- Select Windows Classic Desktop and then Console App (.NET Framework) in the right-hand pane:

- Now, in the Name: text box, type Chapter2.Primitives.PrimitivesConsole and leave the Location: text box as it is.

- Click OK.
- After adding the new project, the Solution Explorer (Ctrl + Alt + L) should look like this:

- Click on the References label in the Chapter2.Primitives.PrimitivesConsole project node. Right-click and select Add | Add Reference.
- In the Reference Manager, select Projects in the left-hand pane and check the Chapter2.Primitives.PrimitiveLib in the right-hand pane:

- Click OK to add the reference to the selected project.
- Now, in the newly added console application project, double-click on Program.cs to open the code window.
- Scroll up and add the following using directive:
using Chapter2.Primitives.PrimitiveLib;
- Now, scroll down and in between the curly braces of the Main() method, type the following code:
var myHelper = new Helpers();
var myGrade = myHelper.WhatIsMyGrade(65);
Console.WriteLine($"You are current grade is {myGrade}");
Console.ReadLine();
- Now press F5 to debug the code.
- You should see output like this:

- Now, press any key to exit the console, click just before the Console.ReadLine() line, and press Enter to add some new code.
- Let's type the following code now:
var cm = 15;
var inches = myHelper.CmToInches(cm);
Console.WriteLine($"{cm} centimeters in inches are {inches}");
- Press F5 to see the output and you should see the following:

- Now that we have successfully tested the library, change some values and see how it works.
推薦閱讀
- UI圖標創意設計
- Java Web開發學習手冊
- Xcode 7 Essentials(Second Edition)
- SQL Server從入門到精通(第3版)
- Learning Hadoop 2
- Java EE企業級應用開發教程(Spring+Spring MVC+MyBatis)
- Java 從入門到項目實踐(超值版)
- Python 3 Object:oriented Programming(Second Edition)
- PHP+MySQL動態網站開發從入門到精通(視頻教學版)
- 征服C指針(第2版)
- 多接入邊緣計算實戰
- SAP HANA Starter
- 程序員超強大腦
- 代碼整潔之道:程序員的職業素養
- Xamarin Cross-platform Application Development(Second Edition)