You can’t add items to an array, since it has fixed length. What you’re looking for is a List<string>
, which can later be turned to an array using list.ToArray()
, e.g.
List<string> list = new List<string>(); list.Add("Hi"); String[] str = list.ToArray();
Related Posts:
- Error : Index was outside the bounds of the array.
- All possible array initialization syntaxes
- Adding values to a C# array
- Adding values to a C# array
- C# equivalent of C++ map
- How to convert byte array to string [duplicate]
- How to convert byte array to string
- Adding values to a C# array
- Adding values to a C# array
- Reading CSV file and storing values into an array
- Remove element of a regular array
- Merging two arrays in .NET
- C# syntax to initialize custom class/objects through constructor params in array?
- Checking if a string array contains a value, and if so, getting its position
- How to convert UTF-8 byte[] to string
- How do I concatenate two arrays in C#?
- Best way to “push” into C# array
- Convert an array to string
- Key Value Pair List
- Convert HTML to PDF in .NET
- C# HttpClient An existing connection was forcibly closed by the remote host
- Can anyone explain IEnumerable and IEnumerator to me? [closed]
- IOException: The process cannot access the file ‘file path’ because it is being used by another process
- No connection could be made because the target machine actively refused it?
- What does a lock statement do under the hood?
- What is C# equivalent of
- ASP.NET 5 MVC: unable to connect to web server ‘IIS Express’
- Why is this code throwing an InvalidOperationException?
- How to add a default Default.aspx to a ASP.NET Web Application Project?
- Regex for numbers only
- Access to the path is denied
- What does question mark and dot operator ?. mean in C# 6.0?
- How to jump in Unity 3d?
- The client and server cannot communicate, because they do not possess a common algorithm – ASP.NET C# IIS TLS 1.0 / 1.1 / 1.2 – Win32Exception
- ToList().ForEach in Linq
- Cannot implicitly convert type ‘customtype’ to ‘othercustomtype’
- Metadata file ‘.dll’ could not be found
- Proper way to initialize a C# dictionary with values
- MSHTML DLL on Windows 10
- Unity 2d jumping script
- Get dictionary value by key
- Invalid URI: The format of the URI could not be determined
- Unity “The associated script can not be loaded” and “Win32Exception: The system cannot find the file specified”
- Convert Linq Query Result to Dictionary
- Get single value from dictionary by key
- What is the difference between “@Scripts.Render” and “
Recommended Hostings
Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.
FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.