Found 26504 Articles for Server Side Programming

Double.GetHashCode() Method in C#

AmitDiwan
Updated on 03-Dec-2019 07:55:39

113 Views

The Double.GetHashCode() method in C# is used to return the hash code for this instance.SyntaxThe syntax is as follows −public override int GetHashCode ();ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main(){       double d1 = 150d;       object ob1 = 1/2;       Console.WriteLine("Double1 Value = "+d1);       Console.WriteLine("Object Value = "+ob1);       Console.WriteLine("Are both the values equal? = "+d1.Equals(ob1));       Console.WriteLine("HashCode of Double1 Value = {0}",       d1.GetHashCode());    } }OutputThis will produce the following output ... Read More

Single.ToString Method in C#

AmitDiwan
Updated on 03-Dec-2019 07:53:18

117 Views

The Single.ToString() method in C# is used to convert the numeric value of this instance to its equivalent string representation.SyntaxThe syntax is as follows −public override string ToString ();ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main(){       float f1 = 10.0f/0.0f;       float f2 = -3.0f;       Console.WriteLine("Value1 (String representation) = "+f1.ToString());       Console.WriteLine("Hashcode for Value1 = "+f1.GetHashCode());       Console.WriteLine("TypeCode for Value1 = "+f1.GetTypeCode());       Console.WriteLine("Is Value1 value is positive or negative infinity? = "+Single.IsInfinity(f1));       ... Read More

SortedDictionary.Item[] Property in C#

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

113 Views

The SortedDictionary.Item[] property in C# is used to get or set the value associated with the specified key.SyntaxThe syntax is as follows −public TValue this[TKey k] { get; set; }Above, the value k is the key of the value to get or set.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(1, "One");       sortedDict.Add(2, "Two");       sortedDict.Add(3, "Three");       sortedDict.Add(4, "Four");       sortedDict.Add(5, "Five");       ... Read More

SortedDictionary.Count Property in C#

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

129 Views

The SortedDictionary.Count property in C# is used to get the number of key/value pairs contained in the SortedDictionary.SyntaxThe syntax is as follows −public int Count { get; }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(); ... Read More

Queue.ToArray Method in C#

AmitDiwan
Updated on 03-Dec-2019 07:40:19

104 Views

The Queue.ToArray() method in C# copies the Queue elements to a new array.SyntaxThe syntax is as follows −public virtual object[] ToArray ();ExampleLet us now see an example − Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(){       Queue queue = new Queue();       queue.Enqueue(1);       queue.Enqueue(2);       queue.Enqueue(3);       queue.Enqueue(4);       queue.Enqueue(5);       Console.WriteLine("Queue...");       foreach(int i in queue){          Console.WriteLine(i);       }       int[] intArr = queue.ToArray();       Console.WriteLine("Convert ... Read More

Stack.CopyTo() Method in C#

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

114 Views

The Stack.CopyTo() method in C# is used to copy the Stack to an existing one-dimensional Array, beginning at the specified array index.SyntaxThe syntax is as follows −public virtual void CopyTo (Array arr, int index);Above, the parameter arr is the one-dimensional Array that is the destination of the elements copied from Stack, whereas the index is the index at which the copy initiates.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);       ... Read More

Queue.Synchronized() Method in C#

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

211 Views

The Queue.Synchronized() method in C# is used to return a new Queue that wraps the original queue and is thread-safe.SyntaxThe syntax is as follows −public static System.Collections.Queue Synchronized (System.Collections.Queue queue);Above, the parameter queue is the queue to synchronize.ExampleLet us now see an example − Live Demousing System; using System.Collections; public class Demo {    public static void Main(){       Queue queue = new Queue();       queue.Enqueue("AB");       queue.Enqueue("BC");       queue.Enqueue("CD");       queue.Enqueue("DE");       queue.Enqueue("EF");       queue.Enqueue("FG");       queue.Enqueue("GH");       queue.Enqueue("HI");       ... Read More

Stack.Clone() Method in C#

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

267 Views

The Stack.Clone() method in C# is used to create a shallow copy of the Stack.SyntaxThe syntax is as follows −public virtual object Clone ();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);       stack.Push(2500);       Console.WriteLine("Stack elements...");       foreach(int val in stack){   ... Read More

Queue.Equals() Method in C#

AmitDiwan
Updated on 03-Dec-2019 07:23:13

173 Views

The Queue.Equals() method in C# is used to check if a queue object is equal to another queue object.SyntaxThe syntax is as follows −public virtual bool Equals (object obj);Above, the parameter obj is for comparison.ExampleLet us now see an example − Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(){       Queue queue = new Queue();       queue.Enqueue("Gary");       queue.Enqueue("Jack");       queue.Enqueue("Ryan");       queue.Enqueue("Kevin");       queue.Enqueue("Mark");       queue.Enqueue("Jack");       queue.Enqueue("Ryan");       queue.Enqueue("Kevin");       Console.WriteLine(queue.Equals(queue));     ... Read More

Queue.Enqueue() Method in C#

AmitDiwan
Updated on 03-Dec-2019 07:20:04

397 Views

The Queue.Enqueue() method in C# is used to add an object to the end of the Queue.SyntaxThe syntax is as follows −public virtual void Enqueue (object ob);Above, the parameter ob is the object to add to the Queue.ExampleLet us now see an example − Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(){       Queue queue = new Queue();       queue.Enqueue("Gary");       queue.Enqueue("Jack");       queue.Enqueue("Ryan");       queue.Enqueue("Kevin");       queue.Enqueue("Mark");       queue.Enqueue("Jack");       queue.Enqueue("Ryan");       queue.Enqueue("Kevin");       ... Read More

Advertisements