Csharp Articles

Page 184 of 196

Decimal.ToUInt32() Method in C#

AmitDiwan
AmitDiwan
Updated on 07-Nov-2019 113 Views

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

Read More

BitConverter.Int64BitsToDouble() Method in C#

AmitDiwan
AmitDiwan
Updated on 07-Nov-2019 129 Views

The BitConverter.Int64BitsToDouble() method in C# is used to reinterpret the specified 64-bit signed integer to a double-precision floating-point number.SyntaxFollowing is the syntax −public static double Int64BitsToDouble (long val);Above, the parameter value is the number to convert.ExampleLet us now see an example to implement the BitConverter.Int64BitsToDouble() method −using System; public class Demo {    public static void Main(){       long d = 9846587687;       Console.Write("Value (64-bit signed integer) = "+d);       double res = BitConverter.Int64BitsToDouble(d);       Console.Write("Value (double-precision floating point number) = "+res);    } }OutputThis will produce the following output −Value (64-bit ...

Read More

BitConverter.DoubleToInt64Bits() Method in C#

AmitDiwan
AmitDiwan
Updated on 07-Nov-2019 120 Views

The BitConverter.DoubleToInt64Bits() method in C# is used to convert the specified double-precision floating-point number to a 64-bit signed integer.SyntaxFollowing is the syntax −public static long DoubleToInt64Bits (double val);Above, Val is the number to convert.ExampleLet us now see an example to implement the BitConverter.DoubleToInt64Bits() method −using System; public class Demo {    public static void Main(){       double d = 5.646587687;       Console.Write("Value = "+d);       long res = BitConverter.DoubleToInt64Bits(d);       Console.Write("64-bit signed integer = "+res);    } }OutputThis will produce the following output −Value = 5.646587687 64-bit signed integer = 4618043510978159912ExampleLet us ...

Read More

DateTime.ToFileTime() Method in C#

AmitDiwan
AmitDiwan
Updated on 07-Nov-2019 578 Views

The DateTime.ToFileTime() method in C# is used to convert the value of the current DateTime object to a Windows file time.SyntaxFollowing is the syntax −public long ToFileTime ();ExampleLet us now see an example to implement the DateTime.ToFileTime() method −using System; public class Demo {    public static void Main() {       DateTime d = DateTime.Now;       Console.WriteLine("Date = {0}", d);       long res = d.ToFileTime();       Console.WriteLine("Windows file time = {0}", res);    } }OutputThis will produce the following output −Date = 10/16/2019 8:17:26 AM Windows file time = 132156874462559390ExampleLet us now ...

Read More

DateTime.ToBinary() Method in C#

AmitDiwan
AmitDiwan
Updated on 07-Nov-2019 757 Views

The DateTime.ToBinary() method in C# is used to serialize the current DateTime object to a 64-bit binary value that can be used to recreate the DateTime object. The return value is a 64-bit signed integer.SyntaxFollowing is the syntax −public long ToBinary ();ExampleLet us now see an example to implement the DateTime.ToBinary() method −using System; public class Demo {    public static void Main() {       DateTime d = new DateTime(2019, 10, 10, 8, 10, 40);       Console.WriteLine("Date = {0}", d);       long res = d.ToBinary();       Console.WriteLine("64-bit binary value : {0}", res); ...

Read More

DateTime.Subtract() Method in C#

AmitDiwan
AmitDiwan
Updated on 07-Nov-2019 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

How to create 2-tuple or pair tuple in C#?

AmitDiwan
AmitDiwan
Updated on 07-Nov-2019 333 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
AmitDiwan
Updated on 07-Nov-2019 145 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
AmitDiwan
Updated on 07-Nov-2019 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.ToUInt16() Method in C#

AmitDiwan
AmitDiwan
Updated on 07-Nov-2019 93 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
Showing 1831–1840 of 1,951 articles
« Prev 1 182 183 184 185 186 196 Next »
Advertisements