Found 2587 Articles for Csharp

DateTimeOffset.ToOffset() Method in C#

AmitDiwan
Updated on 12-Nov-2019 08:05:41

626 Views

The DateTimeOffset.ToOffset() method in C# is used to convert the value of the current DateTimeOffset object to the date and time specified by an offset value.SyntaxFollowing is the syntax −public DateTimeOffset ToOffset (TimeSpan val);Above, the value is the offset to convert the DateTimeOffset value to.ExampleLet us now see an example to implement the DateTimeOffset.ToOffset() method −using System; public class Demo {    public static void Main() {       DateTimeOffset dateTimeOffset = new DateTimeOffset(2019, 9, 10, 4, 20, 30, new TimeSpan(-5, 0, 0));       Console.WriteLine("DateTimeOffset = {0}", dateTimeOffset);       DateTimeOffset res = dateTimeOffset.ToOffset(new TimeSpan(-10, 1, ... Read More

DateTimeOffset.ToLocalTime() Method in C#

AmitDiwan
Updated on 12-Nov-2019 08:03:43

108 Views

The DateTimeOffset.ToLocalTime() method in C# is used to convert the current DateTimeOffset object to a DateTimeOffset object that represents the local time.SyntaxFollowing is the syntax −public DateTimeOffset ToLocalTime ();ExampleLet us now see an example to implement the DateTimeOffset.ToLocalTime() method −using System; public class Demo {    public static void Main() {       DateTimeOffset local;       DateTimeOffset dateTimeOffset = DateTimeOffset.Now;       Console.WriteLine("DateTimeOffset = {0}", dateTimeOffset);       local = dateTimeOffset.ToLocalTime();       Console.WriteLine("Local Time = "+local.ToString());    } }OutputThis will produce the following output −DateTimeOffset = 10/16/2019 11:20:35 AM +00:00 Local Time = ... Read More

DateTimeOffset.ToFileTime() Method in C#

AmitDiwan
Updated on 12-Nov-2019 08:01:37

97 Views

The DateTimeOffset.ToFileTime() method in C# is used to convert the value of the current DateTimeOffset object to a Windows file time. The method returns an Int64 value of the current DateTimeOffset object, expressed as a Windows file time.SyntaxFollowing is the syntax −public long ToFileTime ();ExampleLet us now see an example to implement the DateTimeOffset.ToFileTime() method −using System; public class Demo {    public static void Main() {       DateTimeOffset dateTimeOffset1 = new DateTimeOffset(2019, 11, 10, 6, 20, 10, new TimeSpan(-5, 0, 0));       Console.WriteLine("DateTimeOffset = {0}", dateTimeOffset1);       int hash = dateTimeOffset1.GetHashCode();     ... Read More

DateTimeOffset.GetHashCode() Method in C#

AmitDiwan
Updated on 12-Nov-2019 07:58:33

94 Views

The DateTimeOffset.GetHashCode method in C# is used to return the hash code for the current DateTimeOffset object. This method returns a 32-bit signed integer hash code.SyntaxFollowing is the syntax −public override int GetHashCode ();ExampleLet us now see an example to implement the DateTimeOffset.GetHashCode() method −using System; public class Demo {    public static void Main() {       DateTimeOffset dateTimeOffset1 = new DateTimeOffset(2019, 09, 10, 6, 20, 10, new TimeSpan(-5, 0, 0));       DateTimeOffset dateTimeOffset2 = new DateTimeOffset(2019, 11, 12, 8, 20, 10, new TimeSpan(-5, 0, 0));       Console.WriteLine("DateTimeOffset1 = {0}", dateTimeOffset1);       ... Read More

How to create 7-Tuple or Septuple in C#?

AmitDiwan
Updated on 12-Nov-2019 07:56:40

106 Views

The Tuple class represents a 7-tuple, which is called septet. A tuple is a data structure that has a 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 methodExampleLet us now see an example to implement the 7-tuple in C# −using System; public class Demo {    public static void Main(string[] args) {       Tuple tuple = new Tuple(100, 150, 200, 300, 600, 1000, 2000);       Console.WriteLine("Value (Item1)= " + tuple.Item1); ... Read More

How to create 6-Tuple in C#?

AmitDiwan
Updated on 12-Nov-2019 07:53:44

127 Views

The Tuple class represents a 6-tuple. A tuple is a data structure that has a sequence of elements.It has six 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 component.Item5 − Get the value of the current Tuple object's fifth component.Item6 − Get the value of the current Tuple object's sixth component.ExampleLet us now see an example to implement the 6-tuple in C# −using System; public class Demo {   ... Read More

How to create 5-Tuple or quintuple in C#?

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

134 Views

The Tuple class represents a 5-tuple, which is called quintuple. A tuple is a data structure that has a sequence of elements.It has five 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 component.Item5 − Get the value of the current Tuple object's fifth component.ExampleLet us now see an example to implement the 5-tuple in C# −using System; public class Demo {    public static void Main(string[] args) { ... Read More

DateTimeOffset.AddTicks() Method in C#

AmitDiwan
Updated on 12-Nov-2019 07:46:39

190 Views

The DateTimeOffset.AddTicks() method in C# is used to add a specified number of ticks to the value of this instance.SyntaxFollowing is the syntax −public DateTimeOffset AddTicks (long val);Above, the Val is the ticks, which is a number of 100-nanosecond ticks. To subtract ticks, set a negative value.Let us see the number of ticks value −Time intervalNumber of ticksSecond10, 000, 000Minute600, 000, 000Hour36, 000, 000, 000Day864, 000, 000, 000Week6, 048, 000, 000, 000MonthIt depends on the number of days in the month.Non-leap year315, 360, 000, 000, 000Leap year316, 224, 000, 000, 000ExampleLet us now see an example to implement the DateTimeOffset.AddTicks() ... Read More

Dictionary.Remove() Method in C#

AmitDiwan
Updated on 12-Nov-2019 07:43:25

7K+ Views

The Dictionary.Remove() property in C# is used to remove the value with the specified key from the Dictionary.SyntaxFollowing is the syntax −public bool Remove (TKey key);Above, the key is the key to remove.ExampleLet us now see an example to implement the Dictionary.Remove() property −using System; using System.Collections.Generic; public class Demo {    public static void Main(){       Dictionary dict =       new Dictionary();       dict.Add("One", "Kagido");       dict.Add("Two", "Ngidi");       dict.Add("Three", "Devillers");       dict.Add("Four", "Smith");       dict.Add("Five", "Warner");       Console.WriteLine("Count of elements = "+dict.Count); ... Read More

Dictionary.Keys Property in C#

AmitDiwan
Updated on 12-Nov-2019 07:39:00

306 Views

The Dictionary.Keys property in C# is used to fetch all the keys in the Dictionary.SyntaxFollowing is the syntax −public System.Collections.Generic.Dictionary.KeyCollection Keys { get; }ExampleLet us now see an example to implement the Dictionary.Keys property −using System; using System.Collections.Generic; public class Demo {    public static void Main(){       Dictionary dict =       new Dictionary();       dict.Add("One", "Kagido");       dict.Add("Two", "Ngidi");       dict.Add("Three", "Devillers");       dict.Add("Four", "Smith");       dict.Add("Five", "Warner");       Console.WriteLine("Count of elements = "+dict.Count);       Console.WriteLine("Key/value pairs...");       foreach(KeyValuePair ... Read More

Advertisements