- 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
131 Views
To get the unique identifier for the currently managed thread, the code is as follows −Example Live Demousing System; using System.Threading; public class Demo { public static void Main(){ Thread thread = new Thread(new ThreadStart(demo1)); ThreadPool.QueueUserWorkItem(new WaitCallback(demo2)); Console.WriteLine("ManagedThreadId = "+thread.ManagedThreadId); } public static void demo1(){ Thread.Sleep(2000); } public static void demo2(object stateInfo){ Console.WriteLine("Thread belongs to managed thread pool? = "+Thread.CurrentThread.IsThreadPoolThread); } }OutputThis will produce the following output −ManagedThreadId = 3 Thread belongs to managed thread pool? = TrueExampleLet us now ... Read More
41 Views
To get the type of the Tuple’s element, the code is as follows −Example Live Demousing System; public class Demo { public static void Main(String[] args){ var tuple1 = Tuple.Create(150, 1500, Tuple.Create(50, 100)); var tuple2 = Tuple.Create(150, 1500, Tuple.Create(100, 200)); Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2)); Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode()); Console.WriteLine("Type of Tuple1 = "+tuple1.GetType()); Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode()); Console.WriteLine("Type of Tuple1 = "+tuple2.GetType()); } }OutputThis will produce the following output −Is Tuple1 equal to ... Read More
134 Views
To get the type of the current instance, the code is as follows −Example Live Demousing System; public class Demo { public static void Main(){ string s = "Demo"; Console.WriteLine("String = " +s); Console.WriteLine("String Type = " +s.GetType()); } }OutputThis will produce the following output −String = Demo String Type = System.StringExampleLet us now see another example − Live Demousing System; public class Demo { public static void Main(){ double val1 = 5.5; int val2 = 10; short val3 = 2; ... Read More
73 Views
To get an enumerator for a range of elements in the ArrayList, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(){ ArrayList arrList = new ArrayList(); arrList.Add(100); arrList.Add(200); arrList.Add(300); arrList.Add(400); arrList.Add(500); Console.WriteLine("Display elements in a range..."); IEnumerator demoEnum = arrList.GetEnumerator(1, 3); while (demoEnum.MoveNext()) { Object ob = demoEnum.Current; Console.WriteLine(ob); } } ... Read More
77 Views
To get or set the value of the bit at a specific position in the BitArray, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(){ BitArray arr1 = new BitArray(2); BitArray arr2 = new BitArray(2); arr1[0] = false; arr1[1] = true; Console.WriteLine("BitArray1 length = "+arr1.Length); Console.WriteLine("BitArray1 first element = "+arr1.Get(0)); arr2[0] = false; arr2[1] = true; Console.WriteLine("BitArray2 length = "+arr2.Length); ... Read More
663 Views
To get the first element of the Tuple, the code is as follows −Example Live Demousing System; public class Demo { public static void Main(String[] args){ var tuple1 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500); var tuple2 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500); Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2)); Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode()); Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode()); Console.WriteLine("Tuple1 Item 5th = "+tuple1.Item5); Console.WriteLine("Tuple2 Item 5th = "+tuple2.Item5); Console.WriteLine("Tuple1 Item 1st ... Read More
90 Views
To check if two ListDictionary objects are equal, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ ListDictionary dict1 = new ListDictionary(); dict1.Add("A", "Books"); dict1.Add("B", "Electronics"); dict1.Add("C", "Smart Wearables"); dict1.Add("D", "Pet Supplies"); dict1.Add("E", "Clothing"); dict1.Add("F", "Footwear"); Console.WriteLine("ListDictionary1 elements..."); foreach(DictionaryEntry d in dict1){ Console.WriteLine(d.Key + " " + d.Value); } ListDictionary dict2 ... Read More
287 Views
To check if two List objects are equal, 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
80 Views
To remove the element with the specified key from the Hashtable, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(){ Hashtable hash = new Hashtable(10); hash.Add("1", "A"); hash.Add("2", "B"); hash.Add("3", "C"); hash.Add("4", "D"); hash.Add("5", "E"); hash.Add("6", "F"); hash.Add("7", "G"); hash.Add("8", "H"); hash.Add("9", "I"); hash.Add("10", "J"); Console.WriteLine("Hashtable Key and Value pairs..."); foreach(DictionaryEntry ... Read More
72 Views
To get the fifth element of the Tuple, the code is as follows −Example Live Demousing System; public class Demo { public static void Main(String[] args){ var tuple1 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500); var tuple2 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500); Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2)); Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode()); Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode()); Console.WriteLine("Tuple1 Item 5th = "+tuple1.Item5); Console.WriteLine("Tuple2 Item 5th = "+tuple2.Item5); } }OutputThis will produce the ... Read More