- 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
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
3K+ Views
The GetValue() method of array class in C# gets the value at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.We have set the array values first using the Array.CreateInstance method.Array arr = Array.CreateInstance(typeof(String), 3, 6); arr.SetValue("One", 0, 0); arr.SetValue("Two", 0, 1); arr.SetValue("Three", 0, 2); arr.SetValue("Four", 0, 3); arr.SetValue("Five", 1, 4); arr.SetValue("Six", 1, 5); arr.SetValue("Seven", 1, 2); arr.SetValue("Eight", 1, 3);Then loop throught the array length. This will display all the values using the GetValue() method.for (int i = 0; i < a; i++) for (int j = 0; j < b; j++) Console.WriteLine( arr.GetValue(i, ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
842 Views
The GetUpperBound() method of array class in C# gets the upper bound of the specified dimension in the Array.Firstly, set the array and get the upperbound as shown below −arr.GetUpperBound(0).ToString()The following is an example stating the usage of GetUpperBound() method in C#.Example Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class Program { static void Main(string[] args) { Array arr = Array.CreateInstance(typeof(String), 6); arr.SetValue("One", 0); arr.SetValue("Two", 1); arr.SetValue("Three", 3); arr.SetValue("Four", 4); ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ Views
The GetType() method of array class in C# gets the Type of the current instance (Inherited from Object).To get the type.Type tp = value.GetType();In the below example, we are checking the int value using the type.if (tp.Equals(typeof(int))) Console.WriteLine("{0} is an integer data type.", value)The following is the usage of GetType() method in C#.Exampleusing System public class Program { public static void Main() { object[] values = { (int) 100, (long) 17111}; foreach (var value in values) { Type tp = value.GetType(); if (tp.Equals(typeof(int))) ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
156 Views
Set a list with some values. Here, we have a list of strings.var cars = new List() {"Mercedes", "Audi", "Jaguar" };To sort, simply use Sort() method.cars.Sort();The following is an example showing how to sort a list in C#.Example Live Demousing System; using System.Collections.Generic; public class Program { public static void Main() { var cars = new List() {"Mercedes", "Audi", "Jaguar" }; Console.WriteLine("Original Array ="); foreach (var name in cars) { Console.WriteLine(name); } // sort cars.Sort(); ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
319 Views
The GetLowerBound() method of array class in C# gets the lower bound of the specified dimension in the Array.Firstly, set the array and get the lower bound as shown below −arr.GetLowerBound(0).ToString()The following is an example stating the usage of GetLowerBound() method in C#.Example Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace lower { class Program { static void Main(string[] args) { Array arr = Array.CreateInstance(typeof(String), 3); arr.SetValue("Car", 0); arr.SetValue("Truck", 1); arr.SetValue("Motorbike", 2); Console.WriteLine("Lower Bound {0}",arr.GetLowerBound(0).ToString()); Console.ReadLine(); } } }OutputLower Bound 0
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
249 Views
The GetLongLength method in C# gets a 64-bit integer that represents the number of elements in the specified dimension of the Array.First, set the array.long[,] arr2= new long[15, 35];For a specified dimension of the array, set the index in the GetLongMethod() method like −long len2 = arr2.GetLongLength(0);Let us see the complete example.Example Live Demousing System; class Program { static void Main() { int[,] arr = new int[20, 30]; int len = arr.GetLength(0); Console.WriteLine(len); long[,] arr2= new long[15, 35]; long len2 = arr2.GetLongLength(0); Console.WriteLine(len2); } }Output20 15
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
549 Views
The GetLength gets a 32-bit integer that represents the number of elements in the specified dimension of the Array.First, set the array.int[,] arr = new int[20, 30];For a specified dimension of the array, set the index in the GetLength() method like −Arr.GetLength(1);Example Live Demousing System; class Program { static void Main() { int[,] arr = new int[20, 30]; int len = arr.GetLength(1); Console.WriteLine(len); } }Output30
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
255 Views
The Directory class in C# is used to manipulate the directory structure. It has methods to create, move, remove directories.The following are some of the methods of the Directory class.Sr.No.Method & Description1CreateDirectory(String)Creates all directories and subdirectories in the specified path2Delete(String)Deletes an empty directory3Exists(String)Whether the given path refers to an existing directory4GetCreationTime(String)Gets the creation date and time of a directory.5GetCurrentDirectory()Gets the current working directory6GetFiles(String)Let us learn about the usage of GetFiles() method in Directory class. It displays all the files in the specified directory.Exampleusing System; using System.IO; class Program { static void Main() { // Get all ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
The CopyTo() method in C# is used to copy elements of one array to another array. In this method, you can set the starting index from where you want to copy from the source array.The following is the syntax.CopyTo(dest, index);Here dest = destination arrayindex= starting indexThe following is an example showing the usage of CopyTo(, ) method of array class in C#.Example Live Demousing System; class Program { static void Main() { int[] arrSource = new int[4]; arrSource[0] = 5; arrSource[1] = 9; arrSource[2] = 1; ... Read More