- .NET Standard 2.0 Cookbook
- Fiqri Ismail
- 392字
- 2021-06-25 22:11:36
How to do it...
- Open Visual Studio 2017.
- 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.
- 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.
- Click OK.
- Now, in the Solution Explorer (or press Ctrl + Alt + L), select Chapter2.Primitives. Right-click and, select Add | New Project.
- In the Add New Project dialog box, expand the Visual C# node and select .NET Standard in the left-hand pane.
- In the right-hand pane, select Class Library (.NET Standard):

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

- Click OK.
- Now, the Solution Explorer should look like this:

- Click on Class1.cs and press F2 to rename it. Type Helpers.cs as the new name.
- Select Yes in the confirmation dialog box for renaming.
- Now, double-click on Helpers.cs to open its code window.
- 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;
}
- Press Ctrl + Shift + B to build your code.
- 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;
}
- 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.
- Click File | Save All, or press Ctrl + Shift + S, to save the solution and the class library project.
推薦閱讀
- Data Visualization with D3 4.x Cookbook(Second Edition)
- C# 從入門到項目實踐(超值版)
- Ext JS Data-driven Application Design
- Java程序設(shè)計與計算思維
- Blockly創(chuàng)意趣味編程
- Practical Game Design
- 云計算通俗講義(第3版)
- Python數(shù)據(jù)分析(第2版)
- SAP BusinessObjects Dashboards 4.1 Cookbook
- 深入理解Elasticsearch(原書第3版)
- 大數(shù)據(jù)分析與應(yīng)用實戰(zhàn):統(tǒng)計機器學習之數(shù)據(jù)導向編程
- Visual FoxPro程序設(shè)計習題集及實驗指導(第四版)
- 運用后端技術(shù)處理業(yè)務(wù)邏輯(藍橋杯軟件大賽培訓教材-Java方向)
- 單片機C語言程序設(shè)計實訓100例
- JavaScript腳本特效編程給力起飛