.NET Standard 2.0 Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it...

  1. Open Visual Studio 2017.
  2. Now, open the solution from the previous recipe. Click File | Open | Open Project/Solution, or press Ctrl + Shift + O, and select the Chapter1.StandardLib solution. 
  3. Now, click on the Chapter1.Library solution label. Click File | Add | New Project.
  1. In the Add New Project template dialog box, expand the Visual C# node in the left-hand pane. Select Windows Classic Desktop and select Console App (.NET Framework) from the right-hand pane. 
  1. Now, in the Name: text box, type Chapter1.Standard.HelloConsole and leave the Location: text box as it is. 
  1. Click OK.
  2. Now, the Solution Explorer (if not visible, press Ctrl + Alt + L) should look like this: 
  1. In the Chapter1.StandardLib.HelloConsole project tree, right-click on the References label and select Add Reference....  
  2. Under the Reference Manager dialog box, click on the Projects label in the left-hand pane. In the middle pane, check the Chapter1.StandardLib.HelloUniverse project. 
  1. Click OK.
  2. In the Solution Explorer, double-click on the Program.cs filename under the Chapter1.StandardLib.HelloConsole project. 
  3. Scroll up till you reach the using directive part of the code and add the following code as the last line of that section:
      using Chapter1.StandardLib;
  1. Now, in between the curly brackets of the Main() method, type the following code: 
      var myName = "Fiqri Ismail";
var helloMessage = new HelloUniverse();
Console.WriteLine(helloMessage.SayHello(myName));
Console.ReadLine();
  1. Hit F5 and see the code running: 
  1. Press Enter to exit from the Command Prompt