- 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)
111 Views
To get the TypeCode for value type Decimal, the code is as follows −Example Live Demousing System; public class Demo { public static void Main(){ Decimal val = Decimal.MaxValue; Console.WriteLine("Decimal Value = {0}", val); Console.WriteLine("HashCode = {0}", (val.GetHashCode()) ); TypeCode type = val.GetTypeCode(); Console.WriteLine("TypeCode = "+type); } }OutputThis will produce the following output −Decimal Value = 79228162514264337593543950335 HashCode = 1173356544 TypeCode = DecimalExampleLet us now see another example − Live Demousing System; public class Demo { public static void Main(){ ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
102 Views
To get the hash code for the current Decimal instance, the code is as follows −Example Live Demousing System; public class Demo { public static void Main(){ Decimal val = 135269.38193M; Console.WriteLine("Decimal Value = {0}", val); Console.WriteLine("HashCode = {0}", (val.GetHashCode()) ); } }OutputThis will produce the following output −Decimal Value = 135269.38193 HashCode = 1328665595ExampleLet us now see another example − Live Demousing System; public class Demo { public static void Main(){ Decimal val = Decimal.MaxValue; Console.WriteLine("Decimal Value = {0}", val); Console.WriteLine("HashCode = {0}", (val.GetHashCode()) ); } }OutputThis will produce the following output −Decimal Value = 79228162514264337593543950335 HashCode = 1173356544
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
80 Views
To convert the specified string representation of a logical value to its Boolean equivalent, the code is as follows −Example Live Demousing System; public class Demo { public static void Main(){ bool val; bool flag; val = Boolean.TryParse("true", out flag); Console.WriteLine("Result = "+val); } }OutputThis will produce the following output −Example Live Demousing System; public class Demo { public static void Main() { bool val; bool flag; val = Boolean.TryParse("$", out flag); Console.WriteLine("Result = "+val); } }OutputThis will produce the following output −Result = False
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
To convert the value of the current DateTime object to Coordinated Universal Time (UTC), the code is as follows −Example Live Demousing System; public class Demo { public static void Main() { DateTime d = new DateTime(2019, 12, 11, 7, 11, 25); Console.WriteLine("Date = {0}", d); DateTime res = d.ToUniversalTime(); Console.WriteLine("String representation = {0}", res); } }OutputThis will produce the following output −Date = 11/11/2019 7:11:25 AM String representation = 11/11/2019 7:11:25 AMExampleLet us now see another example − Live Demousing System; public class Demo { public ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
267 Views
To get the capacity of a 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); } Console.WriteLine("Capacity of List1 = "+list1.Capacity); List list2 = new List(); list2.Add("India"); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
183 Views
Let us see an example to get the Union of two HashSetExample Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(){ HashSet set1 = new HashSet(); set1.Add(100); set1.Add(200); set1.Add(300); set1.Add(400); set1.Add(500); set1.Add(600); Console.WriteLine("HashSet1 elements..."); foreach(int ele in set1){ Console.WriteLine(ele); } HashSet set2 = new HashSet(); set2.Add(100); set2.Add(200); set2.Add(300); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
83 Views
To check if HashSet and the specified collection contain the same elements, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main() { HashSet set1 = new HashSet(); set1.Add("One"); set1.Add("Two"); set1.Add("Three"); set1.Add("Four"); set1.Add("Five"); set1.Add("Six"); set1.Add("Seven"); HashSet set2 = new HashSet(); set2.Add("One"); set2.Add("Two"); set2.Add("Three"); set2.Add("Four"); Console.WriteLine("Does it contains the same ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
102 Views
To get an ICollection containing keys 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.Keys; String[] strKeys = new String[dict.Count]; col.CopyTo(strKeys, 0); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
144 Views
To return the underlying type of the current enumeration type, the code is as follows −Example Live Demousing System; public class Demo { enum Vehicle {Car, Bus, Bike, Airplane} public static void Main() { try { Vehicle v = Vehicle.Bike; Type type = v.GetType(); string[] str = type.GetEnumNames(); Console.WriteLine("GetEnumName() to return the constant name = " + str); Type type2 = type.GetEnumUnderlyingType(); Console.Write("Enum Underlying type = "+type2); Console.WriteLine("Listing ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
41 Views
To get the names of the members of the current enumeration type, the code is as follows −Example Live Demousing System; public class Demo { enum Vehicle {Car, Bus, Bike} public static void Main() { try { Type type = typeof(string); string[] str = type.GetEnumNames(); Console.WriteLine("GetEnumName() to return the constant name = " + str); Console.WriteLine("Listing constants .."); for (int i = 0; i < str.Length; i++) Console.Write("{0} ", str[i]); ... Read More