- 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 34493 Articles for Programming
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
739 Views
First, define and initalize an array −int[] p = new int[3] {99, 92, 95};Now, display the array elements −for (j = 0; j < 3; j++ ) { Console.WriteLine("Price of Product[{0}] = {1}", j, p[j]); }To acess any element, just include the index of the element you want like this −p[2];The above is to acess the 3rd element.Now let us see the complete code −Exampleusing System; namespace Program { class Demo { static void Main(string[] args) { int[] p = new int[3] {99, 92, 95}; int j; for (j = 0; j < 3; j++ ) { Console.WriteLine("Price of Product[{0}] = {1}", j, p[j]); } // access int e = p[2]; Console.WriteLine("Product 3rd price: "+e); Console.ReadKey(); } } }
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
358 Views
The Array class is the base class for all the arrays in C#. It is defined in the System namespace.The following are the methods of the Array class in C# −Sr.NoMethod & Description1ClearSets a range of elements in the Array to zero, to false, or to null, depending on the element type.2Copy(Array, Array, Int32)Copies a range of elements from an Array starting at the first element and pastes them into another Array starting at the first element. The length is specified as a 32-bit integer.3CopyTo(Array, Int32)Copies all the elements of the current one-dimensional Array to the specified one-dimensional Array starting ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
182 Views
To access elements from a rectangular array, you just need to set the index of which you want to get the element. Multi-dimensional arrays are also called rectangular array −a[0, 1]; // second elementThe following is an example showing how to work with a rectangular array in C# and access an element −Exampleusing System; namespace Demo { class Program { static void Main(string[] args) { int[, ] a = new int[3, 3]; a[0, 0]= 10; a[0, 1]= 20; ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
2K+ Views
To convert Upper case to Lower case, use the ToLower() method in C#.Let’s say your string is −str = "TIM";To convert the above uppercase string in lowercase, use the ToLower() method −Console.WriteLine("Converted to LowerCase : {0}", str.ToLower());The following is the code in C# to convert character case −Exampleusing System; using System.Collections.Generic; using System.Text; namespace Demo { class MyApplication { static void Main(string[] args) { string str; str = "TIM"; Console.WriteLine("UpperCase : {0}", str); // convert to lowercase Console.WriteLine("Converted to LowerCase : {0}", str.ToLower()); Console.ReadLine(); } } }
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
3K+ Views
To convert trigonometric angles in Radians, multiply by Math.PI/180. This will convert degrees to radians.The following is the code −Exampleusing System; class Program { static void Main() { Console.WriteLine(Math.Cos(45)); double res = Math.Cos(Math.PI * 45 / 180.0); Console.WriteLine(res); } }Above, we converted using the following formulae −Math.PI * angle / 180.0
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
2K+ Views
Value parametersThe value parameters copy the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.This is the default mechanism for passing parameters to a method. In this mechanism, when a method is called, a new storage location is created for each value parameter.The values of the actual parameters are copied into them. Hence, the changes made to the parameter inside the method have no effect on the argument.Reference ParametersA reference parameter is a reference to a memory location of a ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ Views
To convert Lower case to Upper case, use the ToUpper() method in C#.Let’s say your string is −str = "david";To convert the above lowercase string in uppercase, use the ToUpper() method −Console.WriteLine("Converted to UpperCase : {0}", str.ToUpper());The following is the code in C# to convert character case −Exampleusing System; using System.Collections.Generic; using System.Text; namespace Demo { class MyApplication { static void Main(string[] args) { string str; str = "david"; Console.WriteLine("LowerCase : {0}", str); // convert to uppercase Console.WriteLine("Converted to UpperCase : {0}", str.ToUpper()); Console.ReadLine(); } } }
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
230 Views
To acess element from the multi-dimensional array, just add the index for the element you want, for example −a[2,1]The above access element from 3rd row and 2nd column ie element 3 as shown below in out [3,4] array −0 0 1 2 2 4 3 6Let us see whatever we discussed and access element from a 2 dimensional array −Exampleusing System; namespace Program { class Demo { static void Main(string[] args) { int[,] a = new int[4, 2] {{0,0}, {1,2}, {2,4}, {3,6} }; int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 2; j++) { Console.WriteLine("a[{0},{1}] = {2}", i, j, a[i,j]); } } // accessing element Console.WriteLine(a[2,1]); Console.ReadKey(); } } }
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
559 Views
A Jagged array is an array of arrays. To access an element from it, just mention the index for that particular array.Here, we have a jagged array with 5 array of integers −int[][] a = new int[][]{new int[]{0, 0}, new int[]{1, 2}, new int[]{2, 4}, new int[]{ 3, 6 }, new int[]{ 4, 8 } };Let’s say you need to access an element from the 3rd array of integers, for that −a[2][1]Above, we accessed the first element of the 3rd array in a jagged array.Let us see the complete code −Exampleusing System; namespace Demo { class Program { ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
356 Views
C# exceptions are represented by classes. The exception classes in C# are mainly directly or indirectly derived from the System.Exception class.You can also define your own exception. User-defined exception classes are derived from the Exception class.The following is an example −Exampleusing System; namespace UserDefinedException { class TestTemperature { static void Main(string[] args) { Temperature temp = new Temperature(); try { temp.showTemp(); } catch(TempIsZeroException e) { Console.WriteLine("TempIsZeroException: {0}", e.Message); ... Read More