- 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 34489 Articles for Programming
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
143 Views
Use the Math.BigMul() method to find the product of two 32-bit numbers.The following are our two numbers.int one = 345272828; int two = 887685744;Now, get the product.long res; res = Math.BigMul(one, two);Example Live Demousing System; using System.Globalization; class Demo { static void Main() { int one = 345272828; int two = 887685744; long res; res = Math.BigMul(one, two); Console.WriteLine("{0} * {1} = {2}", one, two, res); } }Output345272828 * 887685744 = 306493767206164032
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
3K+ Views
Use the First() method to get the first element from an array.Firstly, set an array.int[] arr = {20, 40, 60, 80 , 100};Now, use the Queryable First() method to return the first element.arr.AsQueryable().First();The following is the entire example.Example Live Demousing System; using System.Linq; using System.Collections.Generic; class Program { static void Main() { int[] arr = {20, 40, 60, 80 , 100}; // getting the first element int res = arr.AsQueryable().First(); Console.WriteLine(res); } }Output20
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
365 Views
The Sortable standard format specifier represents a custom date and time format string.The format string is defined by the DateTimeFormatInfo.SortableDateTimePattern property.The custom format string.yyyy'-'MM'-'dd'T'HH':'mm':'ssExample Live Demousing System; class Demo { static void Main() { DateTime date = new DateTime(2018, 9, 5, 2, 12, 40); Console.WriteLine(date.ToString("s")); } }Output2018-09-05T02:12:40
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
227 Views
The ElementAt() method in C# to get elements at specified index position.Firstly, set the string array.string[] str = { "Jack", "Pat", "David"};Now, to get the element at a particular index, use the ElementAt() method as shown in the following example −Example Live Demousing System.IO; using System; using System.Linq; class Program { static void Main() { string[] str = { "Jack", "Pat", "David"}; Random r = new Random(DateTime.Now.Second); // to generate random string string res = str.AsQueryable().ElementAt(r.Next(0, str.Length)); Console.WriteLine("Random Name = '{0}'", res); } }OutputRandom Name = 'Jack'
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
2K+ Views
Get the difference between two arrays using the Except() method.The following are the two arrays.int[] arr = { 9, 12, 15, 20, 35, 40, 55, 67, 88, 92 }; int[] arr2 = { 20, 35 };To get the difference, use Except() method that returns the first list, except the elements in the second list.arr.AsQueryable().Except(arr2);The following is the entire example.Example Live Demousing System; using System.Linq; using System.Collections.Generic; class Program { static void Main() { int[] arr = { 5, 10, 15, 20, 35, 40 }; int[] except = { 20, 35 }; ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
FomatException is thrown when the format of an argument is invalid.Let us see an example.When we set a value other than int to int.Parse() method, then FormatException is thrown as shown below −Example Live Demousing System; class Demo { static void Main() { string str = "3.5"; int res = int.Parse(str); } }The following error is thrown when the above program is compiled since we have passed a value other than integer.OutputUnhandled Exception: System.FormatException: Input string was not in a correct format.
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
996 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)
324 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)
207 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