- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 2628 Articles for Csharp
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
4K+ Views
The DateTime.AddMonths() method in C# is used to add the specified number of months to the value of this instance.SyntaxFollowing is the syntax −public DateTime AddMonths (int val);Above, Val is the number of months. If you want to subtract months, then set it as negative.ExampleLet us now see an example to implement the DateTime.AddMonths() method −using System; public class Demo { public static void Main(){ DateTime d1 = new DateTime(2019, 05, 15, 5, 15, 25); DateTime d2 = d1.AddMonths(5); System.Console.WriteLine("Initial DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d1); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
46K+ Views
The DateTime.Compare() method in C# is used for comparison of two DateTime instances. It returns an integer value, 0 − If date1 is later than date2SyntaxFollowing is the syntax −public static int Compare (DateTime d1, DateTime d2);Above, d1 and d2 are the two dates to be compared.ExampleLet us now see an example to implement the DateTime.Compare() method −using System; public class Demo { public static void Main(){ DateTime d1 = new DateTime(2019, 11, 20, 6, 20, 40); DateTime d2 = d1.AddYears(5); Console.WriteLine("Initial DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d1); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
588 Views
The Decimal.Compare() method in C# is used to compare two specified Decimal values.SyntaxFollowing is the syntax −public static int Compare (decimal val1, decimal val2);Above, val1 is the first value to compare, whereas Val is the second value to compare.The return value is less than zero if val1 is less than val2. Return value is 0, if Val = val2, whereas greater than zero, if val1 is greater than val2.ExampleLet us now see an example to implement the Decimal.Compare() method −using System; public class Demo { public static void Main(){ Decimal val1 = 45.85m; ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
127 Views
The Type.GetMembers() method in C# is used to get the members (properties, methods, fields, events, etc.) of the current Type.SyntaxFollowing is the syntax −public System.Reflection.MemberInfo[] GetMembers (); public abstract System.Reflection.MemberInfo[] GetMembers (System.Reflection.BindingFlags bindingAttr);ExampleLet us now see an example to implement the Type.GetMembers() method −using System; using System.Reflection; public class Demo { public static void Main(){ Type type = typeof(Subject); try { FieldInfo fieldInfo = type.GetField("SubName"); MemberInfo[] info = type.GetMembers(); Console.Write("Members = "); for (int i = 0; ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
129 Views
The Type.GetMember() method in C# is used to get the specified members of the current Type.SyntaxFollowing is the syntax −public System.Reflection.MemberInfo[] GetMember (string name); public virtual System.Reflection.MemberInfo[] GetMember (string name, System.Reflection.BindingFlags bindingAttr);ExampleLet us now see an example to implement the Type.GetMember() method −using System; using System.Reflection; public class Demo { public static void Main(){ Type type = typeof(Subject); try { FieldInfo fieldInfo = type.GetField("SubName"); MemberInfo[] info = type.GetMember("SubName"); Console.Write("Members = "); for (int i = 0; i ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
6K+ Views
The DateTime.AddMinutes() method in C# is used to add the specified number of minutes to the value of this instance. It returns the new DateTime.SyntaxFollowing is the syntax −public DateTime AddMinutes (double m);Above, m are the minutes to be added. If a negative value is added, then the minutes will get subtracted.ExampleLet us now see an example to implement the DateTime.AddMinutes() method −using System; public class Demo { public static void Main(){ DateTime d1 = new DateTime(2019, 09, 10, 5, 15, 25); DateTime d2 = d1.AddMinutes(25); System.Console.WriteLine("Initial DateTime = {0:dd} ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
The DateTime.AddMilliseconds() method in C# is used to adds the specified number of milliseconds to the value of this instance. This method returns a new DateTime.SyntaxFollowing is the syntax −public DateTime AddMilliseconds (double mSec);Above, mSec is the milliseconds to be added.ExampleLet us now see an example to implement the DateTime.AddMilliseconds() method −using System; public class Demo { public static void Main(){ DateTime d1 = new DateTime(2019, 11, 10, 5, 0, 25); DateTime d2 = d1.AddMilliseconds(1000); System.Console.WriteLine("Initial DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d1); System.Console.WriteLine("New DateTime (After adding ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
35 Views
The Math.Sinh() method in C# is used to return the hyperbolic sine of a specified angle.SyntaxFollowing is the syntax −public static double Sinh(double val)Above, the argument value is the angle.ExampleLet us now see an example to implement the Math.Sinh() method −using System; public class Demo { public static void Main(){ double val1 = 30.0; double val2 = 45.0; Console.WriteLine(Math.Sinh(val1)); Console.WriteLine(Math.Sinh(val2)); } }OutputThis will produce the following output −5343237290762.23 1.74671355287425E+19ExampleLet us see another example to implement the Math.Sinh() method −using System; public class Demo { public ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
602 Views
The Math.Sin() method in C# is used to return the sine of a specified angle.SyntaxFollowing is the syntax −public static double Sin (double val);Above, the argument value is an angle.ExampleLet us now see an example to implement Math.Sin() method −using System; public class Demo { public static void Main(){ double val1 = 30.0; Console.WriteLine(Math.Sin( (val1 * (Math.PI)) / 180 )); } }OutputThis will produce the following output −0.5ExampleLet us see another example to implement Math.Sin() method −using System; public class Demo { public static void Main(){ double val1 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
854 Views
The Math.Sign() method in C# is used to return an integer that indicates the sign of a number.MethodsThe Math.Sign() overloads the following methods −Math.Sign(Int16) Math.Sign(Int32) Math.Sign(Int64) Math.Sign(SByte) Math.Sign(Single) Math.Sign(Decimal) Math.Sign(Double)ExampleLet us now see an example to implement Math.Sign() method −using System; public class Demo { public static void Main(){ short val1 = 1; int val2 = 20; long val3 = -3545465777; Console.WriteLine("Short Value = " + val1); Console.WriteLine("Sign (Short Value) = " + getSign(Math.Sign(val1))); Console.WriteLine("Int32 value = " + val2); ... Read More