
上QQ阅读APP看书,第一时间看更新
How to do it...
- Open Visual Studio 2017.
- Click File | New | Project.
- Now, in the New Project dialog box, expand the Visual C# node in the left-hand pane and select Class Library .NET Standard, and in the right-hand pane, select Class Library (.NET Standard):

- In the Name: text box, type a name for your class library. Let's type Chapter1.StandardLib.HelloUniverse and 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. Finally, in the Solution name: text box, type Chapter1.StandardLib.

- Click OK.
- In the Solution Explorer (press Ctrl + Alt + L) , click on Class1.cs, press F2, and rename it HelloUniverse.cs. Confirm the renaming by selecting Yes in the confirmation box.
- Change the namespace from Chapter1.StandardLib.HelloUniverse to Chapter1.StandardLib.
- Now, in between the curly brackets of the HelloUniverse class, type the following code:
public string SayHello(string name)
{
return $"Hello {name},
welcome to a whole new Universe of .NET Standard 2.0";
}
- Press Ctrl + S to save the changes and press Ctrl + Shift + B to build the code. If the build completes without any errors, we are good to go with the next recipe on how to use this class library.