Found 26504 Articles for Server Side Programming

Indicate whether the specified Unicode character is white space in C#

AmitDiwan
Updated on 10-Dec-2019 08:16:29

221 Views

To indicate whether the specified Unicode character is white space, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main() {       bool res;       char val = ' ';       Console.WriteLine("Value = "+val);       res = Char.IsWhiteSpace(val);       Console.WriteLine("Is the value whitespace? = "+res);    } }OutputThis will produce the following output −Value = Is the value whitespace? = TrueExampleLet us see another example − Live Demousing System; public class Demo {    public static void Main() {       bool res; ... Read More

StringCollection Class in C#

AmitDiwan
Updated on 10-Dec-2019 08:13:49

778 Views

The StringCollection class represents a collection of strings. Following are the properties of the StringCollection class −Sr.noProperty & Description1CountGets the number of key/values pairs contained in the OrderedDictionary collection.2IsReadOnlyGets a value indicating whether the StringCollection is read-only..3IsSynchronizedGets a value indicating whether access to the StringCollection is synchronized (thread safe).4Item[Int32]Gets or sets the element at the specified index.5SyncRootGets an object that can be used to synchronize access to the StringCollection.Following are the methods of the StringCollection class −Sr.noMethod & Description1Add(String)Adds a string to the end of the StringCollection.2AddRange(String[])Copies the elements of a string array to the end of the StringCollection.3Clear()Removes all ... Read More

How to find the Capacity of a StringBuilder in C#

AmitDiwan
Updated on 10-Dec-2019 08:08:03

103 Views

To find the capacity of a StringBuilder in C#, the code is as follows −Example Live Demousing System; using System.Text; public class Demo {    public static void Main(String[] args) {       StringBuilder strBuilder1 = new StringBuilder("Tim");       StringBuilder strBuilder2 = new StringBuilder("Tom");       StringBuilder strBuilder3 = new StringBuilder();       Console.WriteLine("Capacity of StringBuilder1 = "+strBuilder1.Capacity);       Console.WriteLine("Capacity of StringBuilder2 = "+strBuilder2.Capacity);       Console.WriteLine("Capacity of StringBuilder3 = "+strBuilder3.Capacity);       strBuilder2 = strBuilder3;       Console.WriteLine("Is StringBuilder3 equal to StringBuilder2? = "+strBuilder3.Equals(strBuilder2));    } }OutputThis will produce the ... Read More

Total number of elements present in an array in C#

AmitDiwan
Updated on 10-Dec-2019 08:05:46

196 Views

To get the total number of elements present in an array, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main() {       string[] products = { "Electronics", "Accessories", "Clothing", "Toys", "Clothing", "Furniture" };       Console.WriteLine("Products list...");       foreach(string s in products) {          Console.WriteLine(s);       }       Console.WriteLine("Array length = "+products.GetLength(0));       Console.WriteLine("One or more products begin with the letter 'C'? = {0}", Array.Exists(products, ele => ele.StartsWith("C")));       Console.WriteLine("One or more planets begin with 'D'? ... Read More

How to create the StringBuilder in C#?

AmitDiwan
Updated on 10-Dec-2019 08:02:32

156 Views

To create StringBuilder in C#, the code is as follows −Example Live Demousing System; using System.Text; public class Demo {    public static void Main(String[] args) {       StringBuilder strBuilder1 = new StringBuilder("Tim");       StringBuilder strBuilder2 = new StringBuilder("Tom");       Console.WriteLine("Is StringBuilder1 equal to StringBuilder2? = "+strBuilder1.Equals(strBuilder2));    } }OutputThis will produce the following output −Is StringBuilder1 equal to StringBuilder2? = FalseExampleLet us see another example − Live Demousing System; using System.Text; public class Demo {    public static void Main(String[] args) {       StringBuilder strBuilder1 = new StringBuilder("John");       StringBuilder strBuilder2 = new StringBuilder("John");       ... Read More

How to create an OrderedDictionary in C#?

AmitDiwan
Updated on 10-Dec-2019 07:59:41

106 Views

To create an OrderedDictionary in C#, 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("A", "Books");       dict.Add("B", "Electronics");       dict.Add("C", "Smart Wearables");       dict.Add("D", "Pet Supplies");       dict.Add("E", "Clothing");       dict.Add("F", "Footwear");       Console.WriteLine("OrderedDictionary elements...");       foreach(DictionaryEntry d in dict) {          Console.WriteLine(d.Key + " " + d.Value);       }       Console.WriteLine("Count of ... Read More

OrderedDictionary Class in C#

AmitDiwan
Updated on 10-Dec-2019 07:56:50

895 Views

The OrderedDictionary class represents a collection of key/value pairs that are accessible by the key or index.Following are the properties of OrderedDictionary class −Sr.noProperty & Description1CountGets the number of key/values pairs contained in the OrderedDictionary collection.2IsReadOnlyGets a value indicating whether the OrderedDictionary collection is read-only.3Item[Int32]Gets or sets the value at the specified index.4Item[Object]Gets or sets the value with the specified key.5KeysGets an ICollection object containing the keys in the OrderedDictionary collection.6ValuesGets an ICollection object containing the values in the OrderedDictionary collection.Following are some of the methods of the OrderedDictionary class −Sr.noMethod & Description1Add(Object, Object)Adds an entry with the specified key ... Read More

How to find the MaxCapacity of a StringBuilder in C#?

AmitDiwan
Updated on 10-Dec-2019 07:52:41

244 Views

To find the MaxCapacity of a StringBuilder, the code is as follows −Example Live Demousing System; using System.Text; public class Demo {    public static void Main(String[] args) {       StringBuilder strBuilder1 = new StringBuilder("Amy");       StringBuilder strBuilder2 = new StringBuilder("Katie");       StringBuilder strBuilder3 = new StringBuilder();       StringBuilder strBuilder4 = new StringBuilder(5);       strBuilder2 = strBuilder3;       Console.WriteLine("Is StringBuilder3 equal to StringBuilder2? = "+strBuilder3.Equals(strBuilder2));       Console.WriteLine("StringBuider1 capacity = "+strBuilder1.Capacity);       Console.WriteLine("StringBuider1 maximum capacity = "+strBuilder1.MaxCapacity);       Console.WriteLine("StringBuider2 capacity = "+strBuilder2.Capacity);   ... Read More

How to find the length of the StringBuilder in C#?

AmitDiwan
Updated on 10-Dec-2019 07:47:55

245 Views

To find the length of the StringBuilder in C#, the code is as follows −Example Live Demousing System; using System.Text; public class Demo {    public static void Main(String[] args) {       StringBuilder strBuilder1 = new StringBuilder("Amy");       StringBuilder strBuilder2 = new StringBuilder("Katie");       StringBuilder strBuilder3 = new StringBuilder();       StringBuilder strBuilder4 = new StringBuilder(5);       strBuilder2 = strBuilder3;       Console.WriteLine("Is StringBuilder3 equal to StringBuilder2? = "+strBuilder3.Equals(strBuilder2));       Console.WriteLine("StringBuider1 capacity = "+strBuilder1.Capacity);       Console.WriteLine("StringBuider1 maximum capacity = "+strBuilder1.MaxCapacity);       Console.WriteLine("StringBuider1 length = "+strBuilder1.Length); ... Read More

How to create a StringDictionary in C#?

AmitDiwan
Updated on 10-Dec-2019 07:44:37

95 Views

To create a StringDictionary in C#, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main() {       StringDictionary strDict = new StringDictionary();       strDict.Add("A", "John");       strDict.Add("B", "Andy");       strDict.Add("C", "Tim");       strDict.Add("D", "Ryan");       strDict.Add("E", "Kevin");       strDict.Add("F", "Katie");       strDict.Add("G", "Brad");       Console.WriteLine("StringDictionary elements...");       foreach(DictionaryEntry de in strDict) {          Console.WriteLine(de.Key + " " + de.Value);       }    } ... Read More

Advertisements