- 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 34494 Articles for Programming
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
990 Views
To get the size of a 3D array in C#, use the GetLength() method with parameter as the index of the dimensions.GetLength(dimensionIndex)To get the size.arr.GetLength(0) arr.GetLength(1) arr.GetLength(2)Example Live Demousing System; class Program { static void Main() { int[,,] arr = new int[3,4,5]; // length of a dimension Console.WriteLine(arr.GetLength(0)); Console.WriteLine(arr.GetLength(1)); Console.WriteLine(arr.GetLength(2)); // length Console.WriteLine(arr.Length); } }Output3 4 5 60
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
319 Views
BinarySearch() works on a sorted list whether its numeric, alphanumeric or strings. It finds you the index of an element.Let’s say the following is our list.List list = new List(); list.Add(70); list.Add(150); list.Add(220); list.Add(250); list.Add(300);Now to check the index where 250 is placed, use BinarySearch() method.list.BinarySearch(250);Example Live Demousing System; using System.Collections.Generic; class Demo { static void Main() { List list = new List(); list.Add(70); list.Add(150); list.Add(220); list.Add(250); list.Add(300); int value = list.BinarySearch(250); Console.WriteLine("Element 250 at Index: "+value); } }OutputElement 250 at Index: 3
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
159 Views
The "." custom format specifier adds a localized decimal separator into the output string.The 1st period in the format string determines the location of the decimal separator in the formatted value.double d = 2.3; d.ToString("0.00", CultureInfo.InvariantCultureLet us see another example to learn how to implement “.” Custom specifier.Example Live Demousing System; using System.Globalization; class Demo { static void Main() { double d; d = 3.7; Console.WriteLine(d.ToString("0.00", CultureInfo.InvariantCulture)); Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0:0.00}", d)); d = 5.89; Console.WriteLine(d.ToString("00.00", CultureInfo.InvariantCulture)); Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0:00.00}", d)); } }Output3.70 3.70 05.89 05.89
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
203 Views
Firstly, set a Dictionary collection with elements.Dictionary d = new Dictionary() { {1, "Applianes"}, {2, "Clothing"}, {3, "Toys"}, {4, "Footwear"}, {5, "Accessories"} };Now, let’s say you need to check whether key 5 exists or not. For that, use ContainsKey() method. It returns True if key is found.d.ContainsKey(5);Let us see the complete code.Example Live Demousing System; using System.Collections.Generic; public class Program { public static void Main() { Dictionary d = new Dictionary() { {1, "Electronics"}, {2, "Clothing"}, {3, "Toys"}, ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
148 Views
The "#" custom format specifier works as a digit-placeholder symbol.If the value to be formatted has a digit in the position where the "#" symbol appears in the format string, then that digit is copied to the resultant string.We have set a double type here.double d; d = 4.2;Now, let us use the “#” custom specifier.d.ToString("#.##", CultureInfo.InvariantCulture)Here are other examples.Example Live Demousing System; using System.Globalization; class Demo { static void Main() { double d; d = 4.2; Console.WriteLine(d.ToString("#.##", CultureInfo.InvariantCulture)); Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0:#.##}", d)); d = 345; ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ Views
The “0” custom specifier is a zero placeholder.If the value to be formatted has a digit in the position where the zero appears in the format string, the the digit is copied to the resultant string. However, if this doesn’t happen, then a zero appears.Here is our double variable.double d; d = 292;Now, by setting the following, you can easily make zero appear in the format string.d.ToString("00000")Example Live Demousing System; using System.Globalization; class Demo { static void Main() { double d; d = 292; Console.WriteLine(d.ToString("00000")); Console.WriteLine(String.Format("{0:00000}", d)); ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
1K+ Views
To represent Int64 as a Binary string in C#, use the ToString() method and set the base as the ToString() method’s second parameter i.e.16 for Hexadecimal.Int64 represents a 64-bit signed integer.Firstly, set an Int64 variable.long val = 947645;Now, convert it to a hex string by including 16 as the second parameter.Convert.ToString(val, 16)ExampleLive Demousing System; class Demo { static void Main() { long val = 947645; Console.WriteLine("Long: "+val); Console.Write("Hex String: "+Convert.ToString(val, 16)); } }OutputLong: 947645 Hex String: e75bd
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
188 Views
Int64 represents a 64-bit signed integer. To represent it as a string, use the ToString() method.Firstly, declare and initialize an Int64 variable.long val = 8766776;Now, represent it as a string.val.ToString()Let us see the complete example.Example Live Demousing System; class Demo { static void Main() { long val = 8766776; Console.Write("Long converted to string = "+val.ToString()); } }OutputLong converted to string = 8766776
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
2K+ Views
The "D" (or decimal) format specifier works for integer type. It converts a number to a string of decimal digits (0-9).Let’say the following is our number.int val = 467;Now to return the result as 0467, use the following decimal format specifier.val.ToString("D4")Let us see another example.Example Live Demousing System; using System.Globalization; class Demo { static void Main() { int val; val = 877; Console.WriteLine(val.ToString("D")); Console.WriteLine(val.ToString("D4")); Console.WriteLine(val.ToString("D8")); } }Output877 0877 00000877
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
667 Views
OverflowException is thrown when the parameter value is out of integer ranges.Let us see an example.When we set a value to int.Parse() method that is out of integer range, then OverflowException is thrown as shown below −Example Live Demousing System; class Demo { static void Main() { string str = "757657657657657"; int res = int.Parse(str); } }OutputThe following error is thrown when the above program is compiled since we have passed a value that is out of integer (Int32) range.Unhandled Exception: System.OverflowException: Value was either too large or too small for an Int32.