Found 26504 Articles for Server Side Programming

SortedDictionary.ContainsValue() Method in C#

AmitDiwan
Updated on 03-Dec-2019 07:16:27

90 Views

The SortedDictionary.ContainsValue() method in C# is used to determine whether the SortedDictionary contains an element with the specified value.SyntaxThe syntax is as follows −public bool ContainsValue (TValue val);Above, the value val is the value to be searched in the SortedDictionary.ExampleLet us now see an example − Live Demousing System; using System.Collections; using System.Collections.Generic; public class Demo {    public static void Main(){       SortedDictionary sortedDict = new SortedDictionary();       sortedDict.Add(100, "Inspiron");       sortedDict.Add(200, "Alienware");       sortedDict.Add(300, "Projectors");       sortedDict.Add(400, "XPS");       Console.WriteLine("SortedDictionary key-value pairs...");       IDictionaryEnumerator demoEnum ... Read More

TimeSpan.Compare() Method in C#

AmitDiwan
Updated on 03-Dec-2019 07:11:57

2K+ Views

The TimeSpan.Compare() method in C# is used to compare two TimeSpan values and returns an integer that indicates whether the first value is shorter than, equal to, or longer than the second value.The return value is -1 if span1 is shorter than span2, 0 if span1=span2, whereas 1 if span1 is longer than span2.SyntaxThe syntax is as follows −public static int Compare (TimeSpan span1, TimeSpan span2);Above, the parameter span1 is the 1st time interval to compare, whereas span2 is the 2nd interval to compare.ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void ... Read More

TimeSpan.Add() Method in C#

AmitDiwan
Updated on 03-Dec-2019 07:08:50

996 Views

The TimeSpan.Add() method in C# is used to return a new TimeSpan object whose value is the sum of the specified TimeSpan object and this instance.SyntaxThe syntax is as follows −public TimeSpan Add (TimeSpan span);Above, the parameter span is the time interval to add.ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main(){       TimeSpan span1 = new TimeSpan(2, 17, 20, 30);       TimeSpan span2 = new TimeSpan(3, 18, 25, 25);       TimeSpan span3 = new TimeSpan(-8, 30, 0);       TimeSpan res1 = span1.Add(span2); ... Read More

Double.IsInfinity() Method in C#

AmitDiwan
Updated on 03-Dec-2019 07:06:06

114 Views

The Double.IsInfinity() method in C# is used to return a value indicating whether the specified number evaluates to negative or positive infinity.SyntaxThe syntax is as follows −public static bool IsInfinity (double d);Above, the value d is a double-precision floating-point number.ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main(){       double d = 5.5;       Console.WriteLine("Double Value = "+d);       Console.WriteLine("HashCode of Double Value = "+d.GetHashCode());       TypeCode type = d.GetTypeCode();       Console.WriteLine("TypeCode of Double Value = "+type);       Console.WriteLine("Positive ... Read More

SortedDictionary.Clear() Method in C#

AmitDiwan
Updated on 03-Dec-2019 07:03:31

104 Views

The SortedDictionary.Clear() method in C# is used to remove all elements from the SortedDictionary.SyntaxThe syntax is as follows −public void Clear ();ExampleLet us now see an example − Live Demousing System; using System.Collections; using System.Collections.Generic; public class Demo {    public static void Main(){       SortedDictionary sortedDict = new SortedDictionary();       sortedDict.Add(100, "Mobile");       sortedDict.Add(200, "Laptop");       sortedDict.Add(300, "Desktop");       sortedDict.Add(400, "Speakers");       sortedDict.Add(500, "Headphone");       sortedDict.Add(600, "Earphone");       Console.WriteLine("SortedDictionary key-value pairs...");       IDictionaryEnumerator demoEnum = sortedDict.GetEnumerator();       while (demoEnum.MoveNext())   ... Read More

C# SortedDictionary.Add() Method

AmitDiwan
Updated on 03-Dec-2019 07:00:08

158 Views

The SortedDictionary.Add() method in C# is used to add an element with the specified key and value into the SortedDictionary.SyntaxThe syntax is as follows −public void Add (TKey key, TValue val);Above, the value key is the key of the element to add, whereas val is the value of the element to add.ExampleLet us now see an example − Live Demousing System; using System.Collections; using System.Collections.Generic; public class Demo {    public static void Main(){       SortedDictionary sortedDict = new SortedDictionary();       sortedDict.Add(100, "Mobile");       sortedDict.Add(200, "Laptop");       sortedDict.Add(300, "Desktop");       sortedDict.Add(400, ... Read More

TimeSpan.Subtract() Method in C#

AmitDiwan
Updated on 03-Dec-2019 06:56:42

1K+ Views

The TimeSpan.Subtract() method in C# is used to return a new TimeSpan object whose value is the difference between the specified TimeSpan object and this instance.SyntaxThe syntax is as follows −public TimeSpan Subtract (TimeSpan span);Above, the parameter span is the time interval to be subtracted.ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main(){       TimeSpan span1 = TimeSpan.FromTicks(1);       TimeSpan span2 = new TimeSpan(1);       TimeSpan span3 = TimeSpan.FromHours(1);       TimeSpan span4 = TimeSpan.FromMilliseconds(1);       TimeSpan span5 = TimeSpan.FromMinutes(1);     ... Read More

TimeSpan.FromHours() Method in C#

AmitDiwan
Updated on 03-Dec-2019 06:51:14

1K+ Views

The TimeSpan.FromHours() method in C# is used to return a TimeSpan that represents a specified number of hours, where the specification is accurate to the nearest millisecond.SyntaxThe syntax is as follows −public static TimeSpan FromHours (double val);Above, the value val is a number of hours accurate to the nearest millisecond.ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main(){       TimeSpan span1 = TimeSpan.FromDays(0.000323456);       TimeSpan span2 = new TimeSpan(-2, 05, 10);       TimeSpan span3 = TimeSpan.FromHours(5);       Console.WriteLine("TimeSpan1 = "+span1);       ... Read More

Stack.GetEnumerator() Method in C#

AmitDiwan
Updated on 03-Dec-2019 06:47:25

116 Views

The Stack.GetEnumerator() method in C# is used to return an IEnumerator for the Stack.SyntaxThe syntax is as follows −public virtual System.Collections.IEnumerator GetEnumerator ();ExampleLet us now see an example − Live Demousing System; using System.Collections; public class Demo {    public static void Main(){       Stack stack1 = new Stack();       stack1.Push(150);       stack1.Push(300);       stack1.Push(500);       stack1.Push(750);       stack1.Push(1000);       Console.WriteLine("Stack1 elements...");       foreach(int val in stack1){          Console.WriteLine(val);       }       Stack stack2 = new Stack();   ... Read More

Stack.Equals() Method in C#

AmitDiwan
Updated on 03-Dec-2019 06:44:07

321 Views

The Stack.Equals() method in C# is used to check whether a Stack class object is equal to another object or not.SyntaxThe syntax is as follows −public virtual bool Equals (object ob);Above, the parameter ob is the object compared with another.ExampleLet us now see an example − Live Demousing System; using System.Collections; public class Demo {    public static void Main(){       Stack stack = new Stack();       stack.Push(150);       stack.Push(300);       stack.Push(500);       stack.Push(750);       stack.Push(1000);       stack.Push(1250);       stack.Push(1500);       stack.Push(2000);   ... Read More

Advertisements