- 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
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
881 Views
Firstly, set a list with empty string as elements.List myList = new List() { " ", " ", " " };Now let us remove one empty element using index.myList.RemoveAt(0);Example Live Demousing System; using System.Collections.Generic; using System.Linq; class Program { static void Main() { List myList = new List() { " ", " ", " " }; Console.Write("Initial list with empty strings..."); foreach (string list in myList) { ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
274 Views
Firstly, set a a new ArrayList and add elements to it.ArrayList arr = new ArrayList(); arr.Add( "Jones" ); arr.Add( "Tom" ); arr.Add( "Henry" );Now let’s remove the item “Tom”. For that, use the Remove() method.arr.Remove("Tom");The following is the complete example to remove an element from ArrayList −Example Live Demousing System; using System.Collections; class Demo { static void Main(){ ArrayList arr = new ArrayList(); arr.Add( "Jones" ); arr.Add( "Tom" ); arr.Add( "Henry" ); Console.WriteLine("Initial ArrayList..."); foreach(string str in arr) { ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
Declare a new ArrayList and add elements to it.ArrayList arr = new ArrayList(); arr.Add( "One" ); arr.Add( "Two" ); arr.Add( "Three" ); arr.Add( "Four" );Now let’s say you need to remove the element “Three”. For that, use the Remove() method.arr.Remove("Three");The following is the complete example to remove an element from ArrayList −Example Live Demousing System; using System.Collections; class Demo { static void Main() { ArrayList arr = new ArrayList(); arr.Add( "One" ); arr.Add( "Two" ); arr.Add( "Three" ); arr.Add( "Four" ); ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
369 Views
Firstly, declare and initialize one dimensional array.int[] arr = { 35, 12, 66, 90, 34, 2, 64 };Now, use the following to reverse −Array.Reverse(arr);The following is the complete code to reverse a one-dimensional array;Example Live Demousing System; class Demo { static void Main() { int[] arr = { 76, 12, 66, 90, 34, 2, 64 }; // Initial Array Console.WriteLine("Original Array= "); foreach (int i in arr) { Console.WriteLine(i); } // Reverse Array Array.Reverse(arr); Console.WriteLine("Reversed Array= "); foreach (int j in arr) { Console.WriteLine(j); } Console.ReadLine(); } }OutputOriginal Array= 76 12 66 90 34 2 64 Reversed Array= 64 2 34 90 66 12 76
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
4K+ Views
Set maximum value for char.static int maxCHARS = 256;Now display the duplicate characters in the string.String s = "Welcometomywebsite!"; int []cal = new int[maxCHARS]; calculate(s, cal); for (int i = 0; i < maxCHARS; i++) if(cal[i] > 1) { Console.WriteLine("Character "+(char)i); Console.WriteLine("Occurrence = " + cal[i] + " times"); }Above, we have calculated the frequency of characters. The same is shown below in the complete example −Exampleusing System; class Demo { static int maxCHARS = 256; static void calculate(String s, int[] cal) { for (int i = 0; i < ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
12K+ Views
To remove an item from a list in C# using index, use the RemoveAt() method.Firstly, set the list −List list1 = new List() { "Hanks", "Lawrence", "Beckham", "Cooper", };Now remove the element at 2nd position i.e. index 1list1.RemoveAt(1);Let us see the complete example −Example Live Demousing System; using System.Collections.Generic; using System.Linq; class Program { static void Main() { List list1 = new List() { "Hanks", "Lawrence", "Beckham", "Cooper", }; ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
7K+ Views
To read inputs as strings in C#, use the Console.ReadLine() method.str = Console.ReadLine();The above will read input as string. You don’t need to use the Convert method here since the input takes string by default.Now display the string entered by user −Example Live Demousing System; using System.Collections.Generic; class Demo { static void Main() { string myStr; // use ReadLine() to read the entered line myStr = Console.ReadLine(); // display the line Console.WriteLine("Result = {0}", myStr); } }OutputResult =The following is the output. Let’s say the user entered “Amit” as the input −Result = amit
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
184 Views
Firstly, set the characters.char[] arr = new char[5]; arr[0] = 'Y'; arr[1] = 'E'; arr[2] = 'S';Now, convert them into string.string res = new string(arr);The following is the complete code to convert a list of characters into a string −Example Live Demousing System; class Program { static void Main() { char[] arr = new char[5]; arr[0] = 'Y'; arr[1] = 'E'; arr[2] = 'S'; // converting to string string res = new string(arr); Console.WriteLine(res); } }OutputYES
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
26K+ Views
To read inputs as integers in C#, use the Convert.ToInt32() method.res = Convert.ToInt32(val);Let us see how −The Convert.ToInt32 converts the specified string representation of a number to an equivalent 32-bit signed integer.Firstly, read the console input −string val; val = Console.ReadLine();After reading, convert it to an integer.int res; res = Convert.ToInt32(val);Let us see an example −Example Live Demousing System; using System.Collections.Generic; class Demo { static void Main() { string val; int res; Console.WriteLine("Input from user: "); val = Console.ReadLine(); // convert ... Read More