How it works...

In steps 1 to 7, we opened an existing Visual Studio solution and added a new project to it. The newly added project is a .NET-based console application. In steps 9 to 11, we added the reference to the .NET Standard 2.0 library project. This is an important step. To use the functionality in the library, you must add the project as a reference.

In step 13, we added code to use the libraries' first method. The first line of code will define a variable to hold the instance of the Helpers() class. The var keyword helps you to create a local variable without giving an explicit type. It simply tells the compiler to get the type of variable from the expression on the right-hand side of the initialization statement. For example, see the following:  

var myInteger = 10;

This is the same as the following:

int myInteger = 10; 

The second line of code saves the return value from the WhatIsMyGrade() method. The next line will display the output to the console window. The last line will tell the console to wait till a key is pressed. In steps 14 and 15, we see the output of the code we wrote.

In step 17, we are testing the second method inside the Helpers() class inside the .NET Standard 2.0 library we created. In the first line, we created a variable that stores a default value that needs to be converted. In the second line, it stores the converted output in a variable. Again, we have used the var keyword to store the variable, which will automatically store the value with the type returned from the method, in this case to a System.Double. The third line will display the output to the console window. In steps 18 and 19, we executed the console application. 

..................Content has been hidden....................

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