
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 2587 Articles for Csharp

575 Views
To get the number of key/value pairs in the Dictionary, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(){ Dictionary dict = new Dictionary(); dict.Add("One", "Chris"); dict.Add("Two", "Steve"); dict.Add("Three", "Messi"); dict.Add("Four", "Ryan"); dict.Add("Five", "Nathan"); Console.WriteLine("Count of elements = "+dict.Count); Console.WriteLine("Key/value pairs..."); foreach(KeyValuePair res in dict){ Console.WriteLine("Key = {0}, Value = {1}", res.Key, res.Value); ... Read More

484 Views
To reinterpret the specified 64-bit signed integer to a double-precision floating point number, the code is as follows −Example Live Demousing System; public class Demo { public static void Main() { long d = 9846587687; Console.Write("Value (64-bit signed integer) = "+d); double res = BitConverter.Int64BitsToDouble(d); Console.Write("Value (double-precision floating point number) = "+res); } }OutputThis will produce the following output −Value (64-bit signed integer) = 9846587687 Value (double-precision floating point number) = 4.86486070491012E-314ExampleLet us see another example − Live Demousing System; public class Demo { public static void Main() { long d = 20; ... Read More

375 Views
To convert the value of the specified string to its equivalent Unicode character, the code is as follows −Example Live Demousing System; public class Demo { public static void Main(){ bool res; Char ch; res = Char.TryParse("10", out ch); Console.WriteLine(res); Console.WriteLine(ch.ToString()); } }OutputThis will produce the following output −FalseExampleLet us now see another example − Live Demousing System; public class Demo { public static void Main(){ bool res; Char ch; res = Char.TryParse("P", out ch); Console.WriteLine(res); Console.WriteLine(ch.ToString()); } }OutputThis will produce the following output −True P

378 Views
To convert the specified double-precision floating point number to a 64-bit signed integer, the code is as follows −Example Live Demousing System; public class Demo { public static void Main() { double d = 5.646587687; Console.Write("Value = "+d); long res = BitConverter.DoubleToInt64Bits(d); Console.Write("64-bit signed integer = "+res); } }OutputThis will produce the following output −Value = 5.646587687 64-bit signed integer = 4618043510978159912ExampleLet us see another example − Live Demousing System; public class Demo { public static void Main() { double d = 0.001; Console.Write("Value = "+d); ... Read More

280 Views
To convert the value of the current DateTime object to a Windows file time, the code is as follows −Example Live Demousing System; public class Demo { public static void Main() { DateTime d = DateTime.Now; Console.WriteLine("Date = {0}", d); long res = d.ToFileTime(); Console.WriteLine("Windows file time = {0}", res); } }OutputThis will produce the following output −Date = 10/16/2019 8:17:26 AM Windows file time = 132156874462559390ExampleLet us see another example − Live Demousing System; public class Demo { public static void Main() { DateTime d = new DateTime(2019, 05, 10, 6, ... Read More

2K+ Views
A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case.ExampleHere is an example to use strings in a switch statement − Live Demousing System; public class Demo { public static void Main(String[] args){ string grades = "A1"; switch (grades) { case "A1": Console.WriteLine("Very good!"); break; case "A2": ... Read More

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

528 Views
The foreach loop executes a statement or a block of statements for each element in an instance of the type that implements the System.Collections.IEnumerable or System.Collections.Generic.IEnumerable interface.ExampleLet us see an example of foreach loop − Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(){ LinkedList linkedList = new LinkedList(); linkedList.AddLast(25); linkedList.AddLast(50); linkedList.AddLast(100); linkedList.AddLast(200); linkedList.AddLast(400); linkedList.AddLast(500); linkedList.AddLast(550); linkedList.AddLast(600); linkedList.AddLast(800); linkedList.AddLast(1200); Console.WriteLine("Count ... Read More

104 Views
To get an enumerator that iterates through the SortedSet, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main() { SortedSet set1 = new SortedSet(); set1.Add("AB"); set1.Add("BC"); set1.Add("CD"); set1.Add("EF"); Console.WriteLine("Elements in SortedSet1..."); foreach (string res in set1) { Console.WriteLine(res); } SortedSet set2 = new SortedSet(); set2.Add("BC"); set2.Add("CD"); set2.Add("DE"); ... Read More

233 Views
To create a shallow copy of ArrayList in C#, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(){ ArrayList list = new ArrayList(); list.Add("One"); list.Add("Two"); list.Add("Three"); list.Add("Four"); list.Add("Five"); list.Add("Six"); list.Add("Seven"); list.Add("Eight"); Console.WriteLine("ArrayList elements..."); foreach(string str in list){ Console.WriteLine(str); } Console.WriteLine("ArrayList is read-only? = "+list.IsReadOnly); ... Read More