- 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.