- 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)
3K+ Views
The finally keyword is used as a block to execute a given set of statements, whether an exception is thrown or not thrown. For example, if you open a file, it must be closed whether an exception is raised or not.SyntaxFollowing is the syntax −try { // statements causing exception } catch( ExceptionName e1 ) { // error handling code } catch( ExceptionName e2 ) { // error handling code } catch( ExceptionName eN ) { // error handling code } finally { // statements to be executed }ExampleLet us see an example to implement ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
96 Views
To get the HashCode for the current UInt64 instance, the code is as follows −Example Live Demousing System; public class Demo { public static void Main() { ulong val1 = 8768768; ulong val2 = UInt64.MinValue; Console.WriteLine("HashCode for val1 = "+val1.GetHashCode()); Console.WriteLine("HashCode for val2 = "+val2.GetHashCode()); } }OutputThis will produce the following output −HashCode for val1 = 8768768 HashCode for val2 = 0ExampleLet us see another example − Live Demousing System; public class Demo { public static void Main() { ulong val1 = 89879878; ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
55 Views
To return a value indicating whether this instance is equal to a specified object or UInt64, the code is as follows −Example Live Demousing System; public class Demo { public static void Main() { ulong val1 = 44565777; ulong val2 = 77878787; bool res = val1.Equals(val2); Console.WriteLine("Return value (comparison) = "+res); if (res) Console.WriteLine("val1 = val2"); else Console.WriteLine("val1 != val2"); } }OutputThis will produce the following output −Return value (comparison) = False val1 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
77 Views
To get the TypeCode for value type Int32, the code is as follows −Example Live Demousing System; public class Demo { public static void Main() { int val1 = 100; int val2 = 50; Console.WriteLine("Value1 = "+val1); Console.WriteLine("Value2 = "+val2); Console.WriteLine("Are they equal? = "+val1.Equals(val2)); Console.WriteLine("HashCode for Value1 = "+val1.GetHashCode()); Console.WriteLine("HashCode for Value2 = "+val2.GetHashCode()); TypeCode type1 = val1.GetTypeCode(); TypeCode type2 = val2.GetTypeCode(); Console.WriteLine("TypeCode for Value1 = "+type1); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
471 Views
To convert the value of the specified Decimal to the equivalent 64-bit unsigned integer, the code is as follows −Example Live Demousing System; public class Demo { public static void Main() { Decimal val = 99.29m; Console.WriteLine("Decimal value = "+val); ulong res = Decimal.ToUInt64(val); Console.WriteLine("64-bit unsigned integer = "+res); } }OutputThis will produce the following output −Decimal value = 99.29 64-bit unsigned integer = 99ExampleLet us see another example − Live Demousing System; public class Demo { public static void Main(){ Decimal val = 0.001m; Console.WriteLine("Decimal value = ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
50 Views
To indicate whether this instance is equal to a specified object or UInt16, the code is as follows −Example Live Demousing System; public class Demo { public static void Main(){ ushort val1 = 52; ushort val2 = 10; bool res = val1.Equals(val2); Console.WriteLine("Return value (comparison) = "+res); if (res) Console.WriteLine("val1 = val2"); else Console.WriteLine("val1 != val2"); } }OutputThis will produce the following output −Return value (comparison) = False val1 != val2ExampleLet us now ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
340 Views
To convert the value of the specified Decimal to the equivalent 32-bit unsigned integer, the code is as follows −Example Live Demousing System; public class Demo { public static void Main() { Decimal val = 0.001m; Console.WriteLine("Decimal value = "+val); uint res = Decimal.ToUInt32(val); Console.WriteLine("32-bit unsigned integer = "+res); } }OutputThis will produce the following output −Decimal value = 0.001 32-bit unsigned integer = 0ExampleLet us see another example − Live Demousing System; public class Demo { public static void Main() { Decimal val ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
422 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
365 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
261 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