- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 2628 Articles for Csharp
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
629 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
150 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
150 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
53 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
113 Views
To get the type referenced by the specified type handle, the code is as follows −Example Live Demousing System; public class Demo { public static void Main() { Type type1 = typeof(short); RuntimeTypeHandle typeHandle = Type.GetTypeHandle(type1); Type type = Type.GetTypeFromHandle(typeHandle); Console.WriteLine("Attributes = " + type.Attributes); } }OutputThis will produce the following output −Attributes = AutoLayout, AnsiClass, Class, Serializable, BeforeFieldInitExampleLet us see another example − Live Demousing System; public class Demo { public static void Main() { Type type1 = typeof(System.Type); RuntimeTypeHandle ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
261 Views
To convert a specified value to an equivalent Boolean value, the code is as follows −Example Live Demousing System; using System.Globalization; public class Demo { public static void Main() { CultureInfo cultures = new CultureInfo("en-US"); String str = "true"; Console.WriteLine("Converted bool value..."); bool res = Convert.ToBoolean(str, cultures); Console.Write("{0}", res); } }OutputThis will produce the following output −Converted bool value... TrueExampleLet us see another example − Live Demousing System; using System.Globalization; public class Demo { public static void Main() { CultureInfo cultures ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
84 Views
To get or set the value in HybridDictionary with specified key, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo { public static void Main() { HybridDictionary myDict = new HybridDictionary(); myDict.Add("1", "Tablet"); myDict.Add("2", "Desktop"); myDict.Add("3", "Speakers"); myDict.Add("4", "Laptop"); myDict.Add("5", "Notebook"); myDict.Add("6", "Ultrabook"); myDict.Add("7", "HDD"); myDict.Add("8", "SDD"); Console.WriteLine("Value at key 5 = "+myDict["5"]); } }OutputThis will produce the following output −Value at key 5 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
78 Views
To get or set the value at the specified key in StringDictionary, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo { public static void Main() { StringDictionary myDict = new StringDictionary(); myDict.Add("1", "Tablet"); myDict.Add("2", "Desktop"); myDict.Add("3", "Speakers"); myDict.Add("4", "Laptop"); myDict.Add("5", "Notebook"); myDict.Add("6", "Ultrabook"); myDict.Add("7", "HDD"); myDict.Add("8", "SDD"); myDict.Add("9", "Headphone"); myDict.Add("10", "Earphone"); Console.WriteLine("Value for key 5 = "+myDict["5"]); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
82 Views
To remove all the strings from the StringCollection, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo { public static void Main() { StringCollection stringCol = new StringCollection(); String[] arr = new String[] { "100", "200", "300", "400", "500" }; Console.WriteLine("Array elements..."); foreach (string res in arr) { Console.WriteLine(res); } stringCol.AddRange(arr); Console.WriteLine("Does the specified string is in the StringCollection? = "+stringCol.Contains("800")); Console.WriteLine("Total number of elements = "+stringCol.Count); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
90 Views
To remove all the elements from 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"); ... Read More