官术网_书友最值得收藏!

How to do it...

  1. Open Visual Studio 2017.
  2. 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. 
  3. Now click on the Chapter2.Library solution label. Click File | Add | New Project.
  4. In the Add New Project template dialog box, expand the Visual C# node in the left-hand pane. 
  5. Select Windows Classic Desktop and then Console App (.NET Framework) in the right-hand pane:
  1. Now, in the Name: text box, type Chapter2.Primitives.PrimitivesConsole and leave the Location: text box as it is.
  1. Click OK.
  2. After adding the new project, the Solution Explorer (Ctrl + Alt + L) should look like this:
  1. Click on the References label in the Chapter2.Primitives.PrimitivesConsole project node. Right-click and select Add | Add Reference.
  1. In the Reference Manager, select Projects in the left-hand pane and check the Chapter2.Primitives.PrimitiveLib in the right-hand pane:
  1. Click OK to add the reference to the selected project. 
  2. Now, in the newly added console application project, double-click on Program.cs to open the code window.
  3. Scroll up and add the following using directive:
      using Chapter2.Primitives.PrimitiveLib;
  1. 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();
  1. Now press F5 to debug the code. 
  1. You should see output like this: 
  1. Now, press any key to exit the console, click just before the Console.ReadLine() line, and press Enter to add some new code. 
  2. Let's type the following code now: 
      var cm = 15;
var inches = myHelper.CmToInches(cm);
Console.WriteLine($"{cm} centimeters in inches are {inches}");
  1. Press F5 to see the output and you should see the following: 
  1. Now that we have successfully tested the library, change some values and see how it works. 
主站蜘蛛池模板: 菏泽市| 定南县| 克拉玛依市| 黄山市| 铜鼓县| 鄂托克旗| 玉树县| 万宁市| 都昌县| 华安县| 伊宁县| 德格县| 监利县| 饶河县| 麻栗坡县| 平湖市| 灵丘县| 府谷县| 尼勒克县| 日土县| 台州市| 峡江县| 双峰县| 易门县| 正宁县| 塔河县| 招远市| 安康市| 华池县| 甘孜县| 土默特左旗| 黄山市| 滨州市| 长沙县| 治县。| 崇左市| 冷水江市| 黄平县| 威远县| 会同县| 金寨县|