When people uses term .NET, it greatly depends on the context. There is a distinction between C# and .NET as C# is a programing language syntax that can be used to reference and call methods defined in .NET code libraries or assemblies. We can create an assembly from our C# code and use it’s compiler that’s installed with .NET SDK.
.Net standard library can target a number of different platforms. for example, Android, iOS, Linux, Windows etc so In this blog post, We will create a dotnet standard library in an easy way. It will be a very standard class library to demo something. This library will contain two super helpful methods. One method adds two number together and other subtracts one number from the other.
Create a dotnet Standard Library
Prerequisites
- Visual Studio 2019 (If you are following along this blog post)
![create-new-proj](https://acloudtechie.com/wp-content/uploads/2022/01/1-create-new-proj.png)
![c#-class-.net-standard-library](https://acloudtechie.com/wp-content/uploads/2022/01/2-dotnet-standard-library.png)
![configure-new-project](https://acloudtechie.com/wp-content/uploads/2022/01/3-configure-new-project.png)
![dotnet-core-target-framework](https://acloudtechie.com/wp-content/uploads/2022/01/4-dotnet-core-target-framework.png)
![delete-default-class](https://acloudtechie.com/wp-content/uploads/2022/01/5-delete-default-class.png)
![set-default-namespace](https://acloudtechie.com/wp-content/uploads/2022/01/7-set-default-namespace.png)
![add-new-class](https://acloudtechie.com/wp-content/uploads/2022/01/9-add-new-class.png)
Figure 8 – Class named as Calculate
Let’s Start some coding!
Code Snippet
using System; using System.Collections.Generic; using System.Text; namespace ACloudTechie.Artifact.Calculate { public class Calculator { public static double Add(double numOne, double numTwo) { return numOne + numTwo; } public static double Subtract(double numOne, double numTwo) { return numOne - numTwo; } } }
![foundation-calculate-library](https://acloudtechie.com/wp-content/uploads/2022/01/11-foundation-calculate-library.png)