Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2340 of 3366
7K+ Views
The DateTime.AddHours() method in C# is used to add the specified number of hours to the value of this instance. This method returns a new DateTime.SyntaxFollowing is the syntax −public DateTime AddHours (double hrs);Above, hrs are the number of hours to be added. The value can be negative to subtract the hours.ExampleLet us now see an example to implement the DateTime.AddHours() methodusing System; public class Demo { public static void Main(){ DateTime d1 = new DateTime(2019, 11, 2, 9, 0, 10); DateTime d2 = d1.AddHours(2); System.Console.WriteLine("Initial DateTime = {0:dd} {0:y}, ... Read More
10K+ Views
The DateTime.AddDays() method in C# is used to add the specified number of days to the value of this instance. This method returns a new DateTime.SyntaxFollowing is the syntax −public DateTime AddDays (double days);Above, the parameter days are the number of days to be added. To subtract, add a negative value.ExampleLet us now see an example to implement the DateTime.AddDays() method −using System; public class Demo { public static void Main(){ DateTime d1 = new DateTime(2019, 11, 2, 8, 0, 15); DateTime d2 = d1.AddDays(25); System.Console.WriteLine("Initial DateTime = {0:y} {0:dd}", ... Read More
4K+ Views
The DateTime.Add() method in C# is used to return a new DateTime that adds the value of the specified TimeSpan to the value of this instance.SyntaxFollowing is the syntax −public DateTime Add (TimeSpan val);Above, Val is the positive or negative time interval.ExampleLet us now see an example to implement the DateTime.Add() method −using System; public class Demo { public static void Main(){ DateTime d1 = new DateTime(2019, 3, 7, 8, 0, 15); TimeSpan span = new TimeSpan(115, 0, 0, 0); DateTime d2 = d1.Add(span); System.Console.WriteLine("Initial DateTime = ... Read More
539 Views
A Java array is an object which stores multiple variables of the same type, it can hold primitive types and object references whereas JSONArray is an ordered sequence of values. Its external text form is a string wrapped in square brackets with commas separating the values, an internal form is an object having get() and opt() methods for accessing the values by index and element() method for adding or replacing values. In the first step, we can create an Object[] array and pass this parameter as an argument to the toJSON() of JSONSerializer class and typecasting it to get the JSON array.We can convert Object[] array to JSONArray in the below exampleExampleimport ... Read More
292 Views
The Type.GetFields() method in C# is used to get the fields of the current Type.SyntaxFollowing is the syntax −public System.Reflection.FieldInfo[] GetFields ();ExampleLet us now see an example to implement the Type.GetFields() method −using System; using System.Reflection; public class Demo { public static void Main(){ Type type = typeof(System.String); FieldInfo [] fields = type.GetFields(BindingFlags.Static | BindingFlags.NonPublic); Console.WriteLine ("Following are the non-public fields="); foreach (FieldInfo myField in fields){ Console.WriteLine(myField.ToString()); } } }OutputThis will produce the following output −Following are the non-public ... Read More
95 Views
The Type.GetTypeHandle() method in C# is used to get the handle for the Type of a specified object.SyntaxFollowing is the syntax −public static RuntimeTypeHandle GetTypeHandle (object ob);Above, ob is the object for which to get the type handle.Exampleusing System; public class Demo { public static void Main(){ Type type1 = typeof(System.Type); RuntimeTypeHandle typeHandle = Type.GetTypeHandle(type1); Type type = Type.GetTypeFromHandle(typeHandle); Console.WriteLine("Attributes = " + type.Attributes); Console.WriteLine("Type Referenced = "+ type); } }OutputThis will produce the following output −Attributes = AutoLayout, AnsiClass, Class, Serializable, BeforeFieldInit ... Read More
157 Views
The Type.GetTypeFromHandle() method in C# is used to get the type referenced by the specified type handle.SyntaxFollowing is the syntax −public static Type GetTypeFromHandle (RuntimeTypeHandle handle);Above, the handle parameter is the object that refers to the type.ExampleLet us now see an example to implement the Type.GetTypeFromHandle() method −using System; public class Demo { public static void Main(){ Type type1 = typeof(short); RuntimeTypeHandle typeHandle = Type.GetTypeHandle(type1); Type type = Type.GetTypeFromHandle(typeHandle); Console.WriteLine("Attributes = " + type.Attributes); } }OutputThis will produce the following output −Attributes = AutoLayout, AnsiClass, Class, ... Read More
550 Views
The Decimal.Floor() method in C# rounds a specified Decimal number to the closest integer toward negative infinity.SyntaxFollowing is the syntax −public static decimal Floor (decimal val);Above, Val is the value to round.ExampleLet us now see an example to implement the Decimal.Floor() method −using System; public class Demo { public static void Main(){ Decimal val1 = 25.25m; Decimal val2 = 11.85m; Console.WriteLine("Decimal 1 = "+val1); Console.WriteLine("Decimal 2 = "+val2); Console.WriteLine("Floor (val1) = "+Decimal.Floor(val1)); Console.WriteLine("Floor (val2) = "+Decimal.Floor(val2)); } }OutputThis will produce ... Read More
1K+ Views
The Decimal.Divide() method in C# is used to divide two specified Decimal values.SyntaxFollowing is the syntax −public static decimal Divide (decimal val1, decimal val2);Above, val1 is the dividend, whereas val2 is the divisor.ExampleLet us now see an example to implement the Decimal.Divide() method −using System; public class Demo { public static void Main(){ Decimal val1 = 65.15m; Decimal val2 = 5.15m; Console.WriteLine("Decimal 1 = "+val1); Console.WriteLine("Decimal 2 = "+val2); Console.WriteLine("After Division = "+(Decimal.Divide(val1, val2))); } }OutputThis will produce the following output −Decimal 1 ... Read More
143 Views
The Decimal.CompareTo() method in C# is used to compare this instance to a specified object or Decimal and returns an indication of their relative values.SyntaxFollowing is the syntax −public int CompareTo (decimal value); public int CompareTo (object value);ExampleLet us now see an example to implement the Decimal.CompareTo() method −using System; public class Demo { public static void Main(){ Decimal val1 = 65.15m; Decimal val2 = 65.15m; Console.WriteLine("Decimal 1 = "+val1); Console.WriteLine("Decimal 2 = "+val2); Console.WriteLine("Comparison Value = "+(val1.CompareTo(val2))); } }OutputThis will produce the ... Read More