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. 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.69.255