
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
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...
"); foreach (string list in myList) { Console.WriteLine(list); } Console.Write("Removing an empty element from the list...
"); 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 Articles
- How to remove empty strings from a list of strings in Python?
- How to remove empty string/lines from PowerShell?
- Python | Remove empty tuples from a list
- 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 initialize a string to an empty string in C#?
- How to create an empty list in Python?
- How to Remove Empty Lines from a File on ubuntu
- Python Program to Remove the nth Index Character from a Non-Empty String
- How to empty a C# list?
- How to initialize an empty array list in Kotlin?
- How to declare an empty string array in C#?
- Remove new lines from a string and replace with one empty space PHP?
- First Non-Empty String in list in Python

Advertisements