Found 26504 Articles for Server Side Programming

TimeSpan.FromMilliseconds() Method in C#

AmitDiwan
Updated on 04-Dec-2019 10:01:35

587 Views

The TimeSpan.FromMilliseconds() method in C# is used to return a TimeSpan that represents a specified number of milliseconds.The syntax is as follows −Syntaxpublic static TimeSpan FromMilliseconds (double val);Above, val is the number of milliseconds.ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main() {       TimeSpan span1 = TimeSpan.FromDays(15);       TimeSpan span2 = new TimeSpan(5, 15, 30);       TimeSpan span3 = TimeSpan.FromHours(5);       TimeSpan span4 = TimeSpan.FromMilliseconds(876876876.1);       Console.WriteLine("TimeSpan1 = "+span1);       Console.WriteLine("TimeSpan2 = "+span2);       Console.WriteLine("TimeSpan3 = ... Read More

C# String.IsNormalized Method

AmitDiwan
Updated on 04-Dec-2019 09:58:05

194 Views

The String.IsNormalized() method in C# is used to indicate whether this string is in a particular Unicode normalization form.SyntaxThe syntax is as follows −public bool IsNormalized (); public bool IsNormalized (System.Text.NormalizationForm normalizationForm);Above, the parameter normalizationForm is a Unicode normalization form.ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main(String[] args) {       string str1 = "Ryan";       string str2 = "Matt";       Console.WriteLine("String 1 = "+str1);       Console.WriteLine("HashCode of String 1 = "+str1.GetHashCode());       Console.WriteLine("Index of character 'k' in str1 = " ... Read More

Queue.Dequeue Method in C#

AmitDiwan
Updated on 04-Dec-2019 09:48:31

819 Views

The Queue.Dequeue() method in C# is used to remove and return the object at the beginning of the Queue.SyntaxThe syntax is as follows −public virtual object Dequeue ();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("A");       queue.Enqueue("B");       queue.Enqueue("C");       queue.Enqueue("D");       queue.Enqueue("E");       queue.Enqueue("F");       queue.Enqueue("G");       Console.WriteLine("Count of elements = "+queue.Count);       Console.WriteLine("Element at the beginning of ... Read More

Queue.Count Property in C#

AmitDiwan
Updated on 04-Dec-2019 09:42:04

173 Views

The Queue.Count property in C# is used to get the number of elements contained in the Queue.SyntaxThe syntax is as follows −public virtual int Count { get; }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(100);       queue.Enqueue(200);       queue.Enqueue(300);       queue.Enqueue(400);       queue.Enqueue(500);       queue.Enqueue(600);       queue.Enqueue(700);       queue.Enqueue(800);       queue.Enqueue(900);       queue.Enqueue(1000);       Console.WriteLine("Queue..."); ... Read More

Queue.CopyTo() Method in C#

AmitDiwan
Updated on 04-Dec-2019 09:37:29

256 Views

The Queue.CopyTo() method in C# is used to copy the Queue elements to an existing one-dimensional Array, starting 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 Queue. The index parameter is the zero-based index in array at which copying begins.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(100);       ... Read More

Check if a SortedList object contains a specific value in C#

AmitDiwan
Updated on 04-Dec-2019 08:20:54

161 Views

To check if a SortedList object contains a specific value, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main(){       SortedList list = new SortedList();       list.Add("1", "One");       list.Add("2", "Two");       list.Add("3", "Three");       list.Add("4", "Four");       list.Add("5", "Five");       list.Add("6", "Six");       list.Add("7", "Seven");       list.Add("8", "Eight");       Console.WriteLine("Key and Value of SortedList....");       foreach(DictionaryEntry k in list )       Console.WriteLine("Key: {0}, Value: {1}", ... Read More

Get an enumerator that iterates through the List in C#

AmitDiwan
Updated on 04-Dec-2019 08:18:21

561 Views

To get an enumerator that iterates through the List, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(String[] args){       List list1 = new List();       list1.Add("One");       list1.Add("Two");       list1.Add("Three");       list1.Add("Four");       list1.Add("Five");       Console.WriteLine("Elements in List1...");       foreach (string res in list1){          Console.WriteLine(res);       }       List list2 = new List();       list2.Add("India");       list2.Add("US");       list2.Add("UK"); ... Read More

Get the first node of the LinkedList in C#

AmitDiwan
Updated on 04-Dec-2019 08:13:04

387 Views

To get the first node of the LinkedList, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(){       LinkedList list = new LinkedList();       list.AddLast("A");       list.AddLast("B");       list.AddLast("C");       list.AddLast("D");       list.AddLast("E");       list.AddLast("F");       list.AddLast("G");       list.AddLast("H");       list.AddLast("I");       list.AddLast("J");       Console.WriteLine("Count of nodes = " + list.Count);       Console.WriteLine("First Node = "+list.First.Value);       list.Clear();       Console.WriteLine("Count ... Read More

Get an ICollection containing the values in OrderedDictionary in C#

AmitDiwan
Updated on 04-Dec-2019 08:08:06

536 Views

To get an ICollection containing the values in OrderedDictionary, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       OrderedDictionary dict = new OrderedDictionary();       dict.Add("1", "One");       dict.Add("2", "Two");       dict.Add("3", "Three");       dict.Add("4", "Four");       dict.Add("5", "Five");       dict.Add("6", "Six");       dict.Add("7", "Seven");       dict.Add("8", "Eight");       ICollection col = dict.Values;       String[] strVal = new String[dict.Count];       col.CopyTo(strVal, 0);     ... Read More

Check if a Hashtable is equal to another Hashtable in C#

AmitDiwan
Updated on 04-Dec-2019 08:03:47

223 Views

To check if a Hashtable is equal to another Hashtable, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main(){       Hashtable hash1 = new Hashtable();       hash1.Add("1", "Kevin");       hash1.Add("2", "Steve");       hash1.Add("3", "Tim");       hash1.Add("4", "Gary");       hash1.Add("5", "Kevin");       hash1.Add("6", "Steve");       hash1.Add("7", "Tom");       hash1.Add("8", "Stephen");       Console.WriteLine("HashSet1...");       ICollection key = hash1.Keys;       foreach (string k in key) {       ... Read More

Advertisements