Found 2628 Articles for Csharp

BitConverter.Int64BitsToDouble() Method in C#

AmitDiwan
Updated on 07-Nov-2019 06:31:18

50 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
Updated on 07-Nov-2019 06:29:06

45 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

Array.TrueForAll() Method in C#

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

243 Views

The Array.TrueForAll() method in C# is used to determine whether every element in the array matches the conditions defined by the specified predicate.SyntaxFollowing is the syntax −public static bool TrueForAll (T[] array, Predicate match);ExampleLet us now see an example to implement the Array.TrueForAll() method −using System; public class Demo{    public static void Main(){       Console.WriteLine("Array elements...");       string[] arr = { "bike", "bus"};       for (int i = 0; i < arr.Length; i++){          Console.Write("{0} ", arr[i]);       }       Console.WriteLine();       int lastIndex ... Read More

Array.LastIndexOf(T[], T) Method in C#

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

108 Views

The Array.LastIndexOf() method in C# is used to search for the specified object and returns the index of the last occurrence within the entire Array.SyntaxFollowing is the syntax −public static int LastIndexOf (T[] array, T val);Above, the parameter arr is the one-dimensional, zero-based Array to search, whereas Val is the object to locate in an array.ExampleLet us now see an example to implement the Array.LastIndexOf() method −using System; public class Demo{    public static void Main(){       Console.WriteLine("Array elements...");       string[] arr = { "car", "bike", "truck", "bus"};       for (int i = 0; ... Read More

Array.GetEnumerator Method in C#

AmitDiwan
Updated on 07-Nov-2019 06:10:28

183 Views

The Array.GetEnumerator() method in C# is used to return an IEnumerator for the Array.SyntaxFollowing is the syntax −public virtual System.Collections.IEnumerator GetEnumerator ();ExampleLet us now see an example to implement the Array.GetEnumerator() method −using System; using System.Collections; public class Demo{    public static void Main(){       int j = 0;       Console.WriteLine("Array elements...");       string[] arr = { "car", "bike", "truck", "bus"};       for (int i = 0; i < arr.Length; i++){          Console.Write("{0} ", arr[i]);       }       Console.WriteLine();       IEnumerator newEnum = ... Read More

Array.FindLast() Method in C#

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

369 Views

The Array.FindLast() method in C# is used to search for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire Array.SyntaxFollowing is the syntax −public static T FindLast (T[] array, Predicate match);Above, array is the one-dimensional, zero-based Array to search, whereas match is the Predicate that defines the conditions of the element to search for.ExampleLet us now see an example to implement the Array.FindLast() method −using System; public class Demo{    public static void Main(){       Console.WriteLine("Array elements...");       string[] arr = { "car", "bike", "truck", "bus"}; ... Read More

DateTime.ToFileTime() Method in C#

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

369 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
Updated on 07-Nov-2019 06:03:15

595 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
Updated on 07-Nov-2019 06:01:23

939 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
Updated on 07-Nov-2019 05:58:40

192 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

Advertisements