DateTime Subtract Method in C#

AmitDiwan
Updated on 07-Nov-2019 06:01:23

1K+ Views

The DateTime.Subtract() method in C# is used to subtract the specified DateTime or span.SyntaxFollowing is the syntax −public TimeSpan Subtract (DateTime value); public DateTime Subtract (TimeSpan value);ExampleLet us now see an example to implement the DateTime.Subtract() method −using System; public class Demo {    public static void Main() {       DateTime d1 = new DateTime(2019, 10, 10, 8, 10, 40);       DateTime d2 = new DateTime(2017, 11, 06, 8, 10, 40);       Console.WriteLine("Date 1 = "+d1);       Console.WriteLine("Date 2 = "+d2);       TimeSpan res = d1.Subtract(d2);       Console.WriteLine("TimeSpan ... Read More

Create 2-Tuple or Pair Tuple in C#

AmitDiwan
Updated on 07-Nov-2019 05:58:40

314 Views

The Tuple class represents a 2-tuple, which is called pair. A tuple is a data structure that has a sequence of elements.ExampleLet us now see an example to implement the 2-tuple in C# −using System; public class Demo {    public static void Main(string[] args) {       Tuple tuple = new Tuple("jack", "steve");       Console.WriteLine("Value = " + tuple.Item1);       if (tuple.Item1 == "jack") {          Console.WriteLine("Exists: Tuple Value = " +tuple.Item1);       }       if (tuple.Item2 == "david") {          Console.WriteLine("Exists: Tuple Value ... Read More

DateTimeOffset.CompareTo Method in C#

AmitDiwan
Updated on 07-Nov-2019 05:52:43

125 Views

The DateTimeOffset.CompareTo() method in C# is used to compares the current DateTimeOffset object to a specified DateTimeOffset object and indicates whether the current object is earlier than, the same as, or later than the second DateTimeOffset object.It returns an integer value, 0 − If this object is later than ValSyntaxFollowing is the syntax −public int CompareTo (DateTimeOffset val);Above, Val is the object to compare.ExampleLet us now see an example to implement the DateTimeOffset.CompareTo() method −using System; public class Demo {    public static void Main() {       DateTimeOffset dateTimeOffset1 = new DateTimeOffset(2019, 09, 09, 8, 20, 10, new ... Read More

DateTime SpecifyKind Method in C#

AmitDiwan
Updated on 07-Nov-2019 05:50:12

5K+ Views

The DateTime.SpecifyKind() method in C# is used to create a new DateTime object that has the same number of ticks as the specified DateTime but is designated as either local time, Coordinated Universal Time (UTC), or neither, as indicated by the specified DateTimeKind value.SyntaxFollowing is the syntax −public static DateTime SpecifyKind (DateTime d, DateTimeKind kind);Above, the parameter d is the DateTime, whereas kind is One of the enumeration values that indicates whether the new object represents local time, UTC, or neither.ExampleLet us now see an example to implement the DateTime.SpecifyKind() method −using System; using System.Globalization; public class Demo {   ... Read More

Decimal to UInt16 Method in C#

AmitDiwan
Updated on 07-Nov-2019 05:48:06

72 Views

The Decimal.ToUInt16() method in C# is used to convert the value of the specified Decimal to the equivalent 16-bit unsigned integer.SyntaxFollowing is the syntax −public static ushort ToUInt16 (decimal val);Above, the value val is the decimal number to convert.ExampleLet us now see an example to implement the Decimal.ToUInt16() method −using System; public class Demo {    public static void Main(){       Decimal val = 875.647m;       Console.WriteLine("Decimal value = "+val);       ushort res = Decimal.ToUInt16(val);       Console.WriteLine("16-bit unsigned integer = "+res);    } }OutputThis will produce the following output −Decimal value = ... Read More

BigMul Method in C#

AmitDiwan
Updated on 07-Nov-2019 05:45:19

269 Views

The Math.BigMul() method in C# is used to calculate the full product of two 32-bit numbers. The method returns an Int64 integer with the production of both the numbers.SyntaxFollowing is the syntax −public static long BigMul (int val1, int val2);Here, val1 is the 1st number to multiply, whereas val2 is the 2nd number.ExampleLet us now see an example to implement Math.BigMul() method −using System; public class Demo {    public static void Main(){       int val1 = Int32.MaxValue;       int val2 = Int32.MaxValue;       Console.WriteLine("Product of two numbers = " + Math.BigMul(val1, val2));   ... Read More

Math Atan2 Method in C#

AmitDiwan
Updated on 07-Nov-2019 05:42:39

333 Views

The Math.Atan2() method in C# is used to return the angle whose tangent is the quotient of two specified numbers.SyntaxFollowing is the syntax −public static double Atan2 (double val1, double val2);Above, val1 is the y coordinate, whereas val2 is the x coordinate.ExampleLet us now see an example to implement Math.Atan2() method −using System; public class Demo {    public static void Main(){       double val1 = 3.0;       double val2 = 1.0;       double angle, radians;       radians = Math.Atan2(val1, val2);       angle = radians * (180/Math.PI);       ... Read More

Char ToString Method in C#

AmitDiwan
Updated on 07-Nov-2019 05:39:47

172 Views

The Char.ToString() method in C# is used to convert the value of this instance to its equivalent string representation.SyntaxFollowing is the syntax −public override string ToString ();ExampleLet us now see an example to implement the Char.ToString() method −using System; public class Demo {    public static void Main(){       char ch = 'p';       Console.WriteLine("Value = "+ch);       char res1 = Char.ToLowerInvariant(ch);       Console.WriteLine("Lowercase Equivalent = "+res1);       string res2 = ch.ToString();       Console.WriteLine("String Equivalent = "+res2);    } }OutputThis will produce the following output −Value = p ... Read More

Prepare for IBPS Specialist Officer Exam

Swetha Prasanna
Updated on 06-Nov-2019 11:17:47

271 Views

The IBPS notification for a specialist officer is released. This is a dream opportunity for many aspirants who are aiming at prestigious bank jobs. Here is a piece of comprehensive information about how to prepare for IBPS specialist officer job.How IBPS specialist officer is different from other IBPS jobs?Candidates already preparing for IBPS jobs might be aware that there is a focus on quantitative aptitude, reasoning and general awareness sections. For IBPS aspirants already preparing for officer exams, the preparation for specialist exam needs focuses on the core areas for which they are applying for.In general, the IBPS recruits specialist ... Read More

Char ToLowerInvariant Method in C#

AmitDiwan
Updated on 06-Nov-2019 08:06:14

211 Views

The Char.ToLowerInvariant() method in C# is used to convert the value of a Unicode character to its lowercase equivalent using the casing rules of the invariant culture.OutputFollowing is the syntax −public static char ToLowerInvariant (char ch);Above, the parameter ch is the Unicode character to convert.ExampleLet us now see an example to implement the Char.ToLowerInvariant() method −using System; public class Demo {    public static void Main(){       char ch = 'D';       char res = Char.ToLowerInvariant(ch);       Console.WriteLine("Value = "+ch);       Console.WriteLine("Lowercase Equivalent = "+res);    } }OutputThis will produce the following ... Read More

Advertisements