
- 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
C# program to create an empty string array
To create an empty string array −
string[] str = new string[] {};
Above, we haven’t added elements to the array, since it is empty.
Even if we will loop though the array, it won’t display anything as shown below −
Example
using System; public class Demo { public static void Main() { string[] str = new string[] {}; Console.WriteLine("String Array elements won't get displayed since it's empty..."); for (int i = 0; i < str.Length; i++) { string res = str[i]; Console.WriteLine(res); } } }
Output
String Array elements won't get displayed since it's empty...
- Related Articles
- C++ Program to Create an Empty Dictionary
- How to create an empty array in Kotlin?
- How to declare an empty string array in C#?
- Swift Program to Check if an array is empty
- How to create Empty Values String in JavaScript?
- Java Program to create Character Array from String Objects
- Swift program to convert string to an array
- Golang Program to Convert String to an Array
- Java Program to create Stream from a String/Byte Array
- In Javascript how to empty an array
- How to empty an array in Java
- How to empty an array in JavaScript?
- How to create an empty file using Python?
- How to create an empty list in Python?
- How to create an empty dictionary in Python?

Advertisements