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

How to do it...

  1. Open Visual Studio 2017.
  2. Click File | New | Project and, in the New Project template dialog box, select Visual Studio Solutions under the Other Project Types node in the left-hand pane and select Blank Solution in the right-hand pane.
  3. In the Name: text box, type Chapter2.Primitives as the name of the solution. Select a preferred location under the Location: drop-down list or click the Browse... button and select a location. Leave the defaults as they are.



  1. Click OK
  2. Now, in the Solution Explorer (or press Ctrl + Alt + L), select Chapter2.Primitives. Right-click and, select Add | New Project.
  3. In the Add New Project dialog box, expand the Visual C# node and select .NET Standard in the left-hand pane. 
  1. In the right-hand pane, select Class Library (.NET Standard):
  1. Now, in the Name: text box, type Chapter2.Primitives.PrimitiveLib and leave the Location: text box as it is:
  1. Click OK.
  1. Now, the Solution Explorer should look like this: 
  1. Click on Class1.cs and press F2 to rename it. Type Helpers.cs as the new name. 
  2. Select Yes in the confirmation dialog box for renaming. 
  3. Now, double-click on Helpers.cs to open its code window. 
  4. Type the following code in between the curly brackets of the Helpers class: 
      public char WhatIsMyGrade(int yourMarks)
{
var grade = 'F';
if (yourMarks >= 85)
grade = 'A';
else if (yourMarks >= 65)
grade = 'B';
else if (yourMarks >= 55)
grade = 'C';
else if (yourMarks >= 35)
grade = 'S';

return grade;
}
  1. Press Ctrl + Shift + B to build your code. 
  2. Again, type the following code next to the ending curly bracket from step 14:
      public double CmToInches(double cm)
{
var oneCmToInches = 0.393700787;

return oneCmToInches * cm;
}
  1. Let's build our code to check that everything is fine. Click Build | Build Solution or press Ctrl + Shift + B and the solution should build successfully. Let's test our class library in the next recipe. 
  2. Click File | Save All, or press Ctrl + Shift + S, to save the solution and the class library project. 
主站蜘蛛池模板: 宁乡县| 上林县| 庆城县| 灌云县| 长春市| 邢台市| 炉霍县| 三明市| 吉林省| 天柱县| 平潭县| 昔阳县| 白水县| 松潘县| 长泰县| 湘西| 五指山市| 富锦市| 永顺县| 黑龙江省| 德钦县| 定襄县| 江北区| 贵南县| 长子县| 天长市| 凤凰县| 莱西市| 钟山县| 基隆市| 正定县| 开化县| 平南县| 八宿县| 长阳| 桦南县| 芷江| 阳曲县| 宣化县| 岑巩县| 新巴尔虎左旗|