string str1 = "Hello"; string str2 = "World"; string str3 = str1 + " " + str2; // concatenating two strings Console.WriteLine(str3); // output: "Hello World"
double num1 = 1.23456789; double rounded = Math.Round(num1, 2); // round to two decimal places Console.WriteLine(rounded); // output: 1.23 double angle = Math.PI / 2; double sine = Math.Sin(angle); // calculate sine of angle Console.WriteLine(sine); // output: 1
DateTime dt1 = new DateTime(2021, 10, 15); DateTime dt2 = new DateTime(2021, 10, 20); TimeSpan diff = dt2 - dt1; // get time difference between two dates Console.WriteLine(diff.Days); // output: 5 string formatted = dt1.ToString("yyyy-MM-dd"); // format date as yyyy-MM-dd Console.WriteLine(formatted); // output: "2021-10-15"In conclusion, C# Common is a versatile package library that provides a wide range of functions that are useful in various areas of C# programming. It's an excellent tool for developers who want to speed up their development process and simplify common programming tasks.