DateTimeOffset.FromUnixTimeSeconds Method in C#

AmitDiwan
Updated on 06-Nov-2019 06:56:10

935 Views

The DateTimeOffset.FromUnixTimeSeconds() method in C# is used to convert a Unix time expressed as the number of seconds that have elapsed since 1970-01-01T00:00:00Z to a DateTimeOffset value.SyntaxFollowing is the syntax −public static DateTimeOffset FromUnixTimeSeconds (long val);Above, the parameter value is a Unix time, expressed as the number of seconds that have elapsed since 1970-01-01T00:00:00Z (January 1, 1970, at 12:00 AM UTC).ExampleLet us now see an example to implement the DateTimeOffset.FromUnixTimeSeconds() method −using System; public class Demo {    public static void Main() {       DateTimeOffset offset = DateTimeOffset.FromUnixTimeSeconds(20);       Console.WriteLine("DateTimeOffset = {0} ", offset);     ... Read More

DateTimeOffset FromUnixTimeMilliseconds Method in C#

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

1K+ Views

The DateTimeOffset.FromUnixTimeMilliseconds() method in C# is used to convert a Unix time expressed as the number of milliseconds that have elapsed since 1970-01-01T00:00:00Z to a DateTimeOffset value.SyntaxFollowing is the syntax −public static DateTimeOffset FromUnixTimeMilliseconds (long val);Above, Val are the milliseconds that have elapsed since 1970-01-01T00:00:00Z (January 1, 1970, at 12:00 AM UTC).ExampleLet us now see an example to implement the DateTimeOffset.FromUnixTimeMilliseconds() method −using System; public class Demo {    public static void Main() {       DateTimeOffset offset = DateTimeOffset.FromUnixTimeMilliseconds(30000);       Console.WriteLine("DateTimeOffset = {0} ", offset);       Console.WriteLine("DateTimeOffset (other format) = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", ... Read More

GetElementType Method in C#

AmitDiwan
Updated on 06-Nov-2019 06:43:12

248 Views

The Type.GetElementType() method in C# is used to return the Type of the object encompassed or referred to by the current array, pointer or reference type.SyntaxFollowing is the syntax −public abstract Type GetElementType ();ExampleLet us now see an example to implement the Type.GetElementType() method −using System; public class Demo {    public static void Main(){       string[] arr = {"tom", "amit", "kevin", "katie"};       Type t1 = arr.GetType();       Type t2 = t1.GetElementType();       Console.WriteLine("Type = "+t2.ToString());    } }OutputThis will produce the following output −Type = System.StringExampleLet us now see another ... Read More

Tuple Class in C#

AmitDiwan
Updated on 06-Nov-2019 06:32:34

177 Views

The Tuple class represents a 4-tuple, which is called quadruple. A tuple is a data structure that has sequence of elements.It is used in −Easier access to a data set.Easier manipulation of a data set.To represent a single set of data.To return multiple values from a methodTo pass multiple values to a methodIt has four properties −Item1 − Get the value of the current Tuple object's first component.Item2 − Get the value of the current Tuple object's second component.Item3 − Get the value of the current Tuple object's third component.Item4 − Get the value of the current Tuple object's fourth ... Read More

Math Tan Method in C#

AmitDiwan
Updated on 06-Nov-2019 06:28:21

264 Views

The Math.Tan() method in C# is used to return the tangent of the specified angle.SyntaxFollowing is the syntax −public static double Tan (double val);Here, Val is the angle.ExampleLet us now see an example to implement Math.Tan() method −using System; public class Demo {    public static void Main(){       double val1 = 30.0;       Console.WriteLine(Math.Tan( (val1 * (Math.PI)) / 180 ));    } }SyntaxThis will produce the following output −0.577350269189626ExampleLet us see another example to implement Math.Tan() method −using System; public class Demo {    public static void Main(){       double val1 = 45.0; ... Read More

Math Sqrt Method in C#

AmitDiwan
Updated on 06-Nov-2019 06:26:41

5K+ Views

The Math.Sqrt() method in C# is used to compute the square root of the specified number.SyntaxFollowing is the syntax −public static double Sqrt (double val);Above, Val is the number for which we want the square root.ExampleLet us now see an example to implement Math.Sqrt() method −using System; public class Demo {    public static void Main(){       double val1 = 4;       double val2 = 36;       Console.WriteLine(Math.Sqrt(val1));       Console.WriteLine(Math.Sqrt(val2));    } }OutputThis will produce the following output −2 6ExampleLet us see another example to implement Math.Sqrt() method −using System; public class ... Read More

Add Years to DateTime in C#

AmitDiwan
Updated on 06-Nov-2019 06:23:49

4K+ Views

The DateTime.AddYears() method in C# is used to add the specified number of years to the value of this instance. It returns new DateTime.SyntaxFollowing is the syntax −public DateTime AddYears (int yrs);Above, yrs are the years to be added. If you want to subtract years, then use a negative value.ExampleLet us now see an example to implement the DateTime.AddYears() method −using System; public class Demo {    public static void Main(){       DateTime d1 = new DateTime(2019, 11, 20, 6, 20, 40);       DateTime d2 = d1.AddYears(5);       Console.WriteLine("Initial DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ... Read More

Math Pow Method in C#

AmitDiwan
Updated on 06-Nov-2019 06:21:59

5K+ Views

The Math.Pow() method in C# is used to compute a number raised to the power of some other number.SyntaxFollowing is the syntax −public static double Pow(double val1, double val2)Above, val1 is a double-precision floating-point number to be raised to a power., whereas val2 is a double-precision floating-point number that specifies a power.ExampleLet us now see an example to implement Math.Pow() method −using System; public class Demo {    public static void Main(){       double res;       res = Math.Pow(5, 0);       Console.WriteLine("Math.Pow(5, 0) = "+res);       res = Math.Pow(0, 5);     ... Read More

Min Method in C#

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

3K+ Views

The Math.Min() method in C# is used to return the larger of two specified numbers. This method works for both the numbers being Double, Decimal, Int16, Int32, etc.SyntaxFollowing is the syntax −public static ulong Min (ulong val1, ulong val2); public static uint Min (uint val1, uint val2); public static ushort Min (ushort val1, ushort val2); public static float Min (float val1, float val2); public static byte Min (byte val1, byte val2); public static long Min (long val1, long val2);ExampleLet us now see an example to implement Math.Min() method −using System; public class Demo {    public static void Main(){   ... Read More

char.ConvertFromUtf32 Method in C#

AmitDiwan
Updated on 06-Nov-2019 06:18:29

469 Views

The Char.ConvertFromUtf32(Int32) method in C# is used to converts the specified Unicode code point into a UTF-16 encoded string.SyntaxFollowing is the syntax −public static string ConvertFromUtf32 (int utf32);Above, the parameter utf32 is a 21-bit Unicode code point.ExampleLet us now see an example to implement the Char.ConvertFromUtf32(Int32) method −using System; public class Demo {    public static void Main(){       int utf = 0x0051;       string str = Char.ConvertFromUtf32(utf);       Console.WriteLine("Value = "+str);    } }OutputThis will produce the following output −Value = QExampleLet us now see another example −using System; public class Demo { ... Read More

Advertisements