

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to remove an empty string from a list of empty strings in C#?
Firstly, set a list with empty string as elements.
List<string> myList = new List<string>() { " ", " ", " " };
Now let us remove one empty element using index.
myList.RemoveAt(0);
Example
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main() { List<string> myList = new List<string>() { " ", " ", " " }; Console.Write("Initial list with empty strings...\n"); foreach (string list in myList) { Console.WriteLine(list); } Console.Write("Removing an empty element from the list...\n"); myList.RemoveAt(0); foreach (string list in myList) { Console.WriteLine(list); } Console.WriteLine("Empty List after deleting an empty element is shown above..."); } }
Output
Initial list with empty strings... Removing an empty element from the list... Empty List after deleting an empty element is shown above...
- Related Questions & Answers
- How to remove empty strings from a list of strings in Python?
- Python | Remove empty tuples from a list
- How to remove empty string/lines from PowerShell?
- How to filter empty string values from a Java List?
- How to remove empty rows from an R data frame?
- How to initialize a list to an empty list in C#?
- How to empty a C# list?
- How to Remove Empty Lines from a File on ubuntu
- How to create an empty list in Python?
- How to initialize a string to an empty string in C#?
- Python Program to Remove the nth Index Character from a Non-Empty String
- How to initialize an empty array list in Kotlin?
- How to declare an empty string array in C#?
- Empty List in C#
- From a list of IDs with empty and non-empty values, retrieve specific ID records in JavaScript
Advertisements