Server Side Programming Articles - Page 2106 of 2650

DateTime.FromFileTime() Method in C#

AmitDiwan
Updated on 07-Nov-2019 07:19:10

158 Views

The DateTime.FromFileTime() method in C# is used to convert the specified Windows file time to an equivalent local time.SyntaxFollowing is the syntax −public static DateTime FromFileTime (long fileTime);Above, the parameter lifetime is a Windows file time expressed in ticks.ExampleLet us now see an example to implement the DateTime.FromFileTime() method −using System; public class Demo {    public static void Main() {       DateTime d1 = DateTime.FromFileTime(100000000000);       System.Console.WriteLine("DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d1);    } }OutputThis will produce the following output −DateTime = 01 January 1601, 02:46:40ExampleLet us now see another example to implement the ... Read More

DateTime.FromBinary() Method in C#

AmitDiwan
Updated on 07-Nov-2019 07:15:54

258 Views

The DateTime.FromBinary() method in C# is used to deserialize a 64-bit binary value and recreates an original serialized DateTime object.SyntaxFollowing is the syntax −public static DateTime FromBinary (long val);Above, Val is a 64-bit signed integer that encodes the Kind property in a 2-bit field and the Ticks property in a 62-bit field.ExampleLet us now see an example to implement the DateTime.FromBinary() method −using System; public class Demo {    public static void Main() {       DateTime d1 = new DateTime(2019, 11, 10, 6, 20, 45);       long val = d1.ToBinary();       DateTime d2 = ... Read More

DateTime.Equals() Method in C#

AmitDiwan
Updated on 07-Nov-2019 07:12:51

2K+ Views

The DateTime.Equals() method in C# is used check whether two DateTime objects or instances are equal or not. TRUE is returned if both are equal, else FALSE would be the return value.SyntaxFollowing is the syntax −public static bool Equals (DateTime date1, DateTime date2);ExampleLet us now see an example to implement the DateTime.Equals() method −using System; public class Demo {    public static void Main() {       DateTime d1 = new DateTime(2019, 09, 10, 5, 15, 25);       DateTime d2 = d1.AddMonths(25);       Console.WriteLine("Initial DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d1);       Console.WriteLine("New ... Read More

MathF.Sqrt() Method in C# with Examples

AmitDiwan
Updated on 07-Nov-2019 07:10:34

307 Views

The MathF.Sqrt() method in C# is used to compute the square root of the floating-point value.SyntaxFollowing is the syntax −public static float Sqrt (float val);Above, Val is the number whose square root is to be computed.ExampleLet us now see an example to implement the MathF.Sqrt() method −using System; public class Demo {    public static void Main(){       float val1 = 36f;       float val2 = float.NaN;       Console.WriteLine("MathF.Sqrt(val1) = "+MathF.Sqrt(val1));       Console.WriteLine("MathF.Sqrt(val2) = "+MathF.Sqrt(val2));    } }OutputThis will produce the following output −MathF.Sqrt(val1) = 6 MathF.Sqrt(val2) = NaNExampleLet us now see ... Read More

MathF.Sinh() Method in C# with Examples

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

122 Views

The MathF.Sinh() method in C# returns the hyperbolic sine of a floating-point argument.SyntaxFollowing is the syntax −public static float Sinh (float val);Above, Val is the number whose hyperbolic sine is to be returned.ExampleLet us now see an example to implement the MathF.Sinh() method −using System; public class Demo {    public static void Main(){       float val1 = float.PositiveInfinity;       float val2 = float.NegativeInfinity;       float val3 = (20f * (MathF.PI)) / 180;       Console.WriteLine("MathF.Sinh(val1) = "+MathF.Sinh(val1));       Console.WriteLine("MathF.Sinh(val2) = "+MathF.Sinh(val2));       Console.WriteLine("MathF.Sinh(val3) = "+MathF.Sinh(val3));    } }OutputThis ... Read More

MathF.Sin() Method in C# with Examples

AmitDiwan
Updated on 07-Nov-2019 07:02:22

165 Views

The MathF.Sin() method in C# is used to return the sine of a given float value argument.SyntaxFollowing is the syntax −public static float Sin (float val);Above, Val is the angle whose sine is to be returned.ExampleLet us now see an example to implement the MathF.Sin() method −using System; public class Demo {    public static void Main(){       float val1 = 10f;       float val2 = float.NaN;       Console.WriteLine("MathF.Tan(val1) = "+MathF.Tan(val1));       Console.WriteLine("MathF.Tan(val2) = "+MathF.Tan(val2));    } }OutputThis will produce the following output −MathF.Sign(val1) = -0.5440211 MathF.Sign(val2) = NaNExampleLet us now see ... Read More

DateTime.CompareTo() Method in C#

AmitDiwan
Updated on 07-Nov-2019 07:00:02

950 Views

The DateTime.CompareTo() method in C# is used to compare the value of this instance to a specified DateTime value.SyntaxFollowing is the syntax −public int CompareTo (DateTime val);Above, Val is the date to be compared.It returns an integer value, 0 − If this instance is later than ValExampleLet us now see an example to implement the DateTime.CompareTo() method −using System; public class Demo {    public static void Main(){       DateTime date1 = new DateTime(2019, 05, 20, 6, 20, 40);       DateTime date2 = new DateTime(2019, 05, 20, 6, 20, 40);       Console.WriteLine("DateTime 1 = ... Read More

Type.GetInterfaces() Method in C#

AmitDiwan
Updated on 07-Nov-2019 06:57:26

196 Views

The Type.GetInterfaces() method in C# is used to get all the interfaces implemented or inherited by the current Type.SyntaxFollowing is the syntax −public abstract Type[] GetInterfaces ();ExampleLet us now see an example to implement the Type.GetInterfaces() method −using System; public class Demo {    public static void Main(){       Type type = typeof(float);       Type myInterface = type.GetInterface("IFormattable", true);       Type[] myInterfaces = type.GetInterfaces();       Console.WriteLine("Interface = "+myInterface);       Console.WriteLine("All the Interfaces...");       for (int i = 0; i < myInterfaces.Length; i++)       Console.WriteLine(""+myInterfaces[i]);    } ... Read More

Type.GetInterface() Method in C#

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

238 Views

The Type.GetInterface() method in C# is used to get a specific interface implemented or inherited by the current Type.SyntaxFollowing is the syntax −public Type GetInterface (string name); public abstract Type GetInterface (string name, bool ignoreCase);ExampleLet us now see an example to implement the Type.GetInterface() method −using System; public class Demo {    public static void Main(){       Type type = typeof(double);       Type myInterface = type.GetInterface("IFormattable");       Console.WriteLine("Interface = "+myInterface);    } }OutputThis will produce the following output −Interface = System.IFormattableExampleLet us now see another example to implement the Type.GetInterface() method −using System; public ... Read More

UInt64.GetTypeCode() Method in C# with Examples

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

96 Views

The UInt64.GetTypeCode() method in C# is used to return the TypeCode for value type UInt64.SyntaxFollowing is the syntax −public TypeCode GetTypeCode ();ExampleLet us now see an example to implement the UInt64.GetTypeCode() method −using System; public class Demo {    public static void Main(){       ulong val1 = 55;       ulong val2 = 100;       TypeCode type1 = val1.GetTypeCode();       TypeCode type2 = val2.GetTypeCode();       Console.WriteLine("Typecode for val1 = "+type1);       Console.WriteLine("Typecode for val2 = "+type2);    } }OutputThis will produce the following output −Typecode for val1 = UInt64 ... Read More

Advertisements