About 407,000 results
Open links in new tab
  1. C# | Arrays of Strings - GeeksforGeeks

    Nov 19, 2019 · Example: To show String [] args is an array of string. C# string array is basically an array of objects. It doesn’t matter whether you are creating an array of string using string keyword or String class object. Both are same.

  2. c# - Options for initializing a string array - Stack Overflow

    Sep 3, 2013 · string[] myString = new string[]{"string1", "string2"}; or. string[] myString = new string[4]; myString[0] = "string1"; // etc. Advanced: From a List. list<string> = new list<string>(); //... read this in from somewhere string[] myString = list.ToArray(); From StringCollection

  3. C# Arrays - W3Schools

    We have now declared a variable that holds an array of strings. To insert values to it, we can use an array literal - place the values in a comma-separated list, inside curly braces: string[] cars = {"Volvo", "BMW", "Ford", "Mazda"};

  4. Implementing C# String Array - C# Corner

    In this article, you will learn how to implement an array of strings in C#. There are there common ways to implement string arrays in C#: ArrayList class. 1. Array of strings. The simplest form of an array of strings is using string syntaxes on a string type. …

  5. How to Initialize, assign and return a string array in c#

    Oct 5, 2017 · string[] sArray = new string[] {"hi", "hello", "foo"}; Or you can also do this: string str1 = "hi"; string str2 = "this"; string str3 = "is"; string str4 = "sample array"; string[] sArray = {str1, str2, str3, str4};

  6. String Array in C# | Learn Initialization of String Array and …

    Mar 17, 2023 · Guide to the String Array in C#. Here we discuss the basic concept, Declaration Syntax, Initialization of String Array along with examples.

  7. Creating string array in C# - A-Z Tech

    Oct 18, 2018 · The examples below show declaring, initializing, and accessing string arrays in different ways. An example of a string array. In this example, an array is declared and initialized without specifying the array size. The values are also assigned at the time of declaration.

  8. How to Add Values to a String Array in C#? - AspDotnetHelp.com

    Sep 15, 2023 · Here is a complete example with all the methods to add values to a C# string array. class Program. static void Main(string[] args) // Method 1: Initialization. string[] names = {"Emily", "Sophia", "Olivia"}; PrintArray("After Initialization", names); // Method 2: Using index. names = new string[3]; names[0] = "Jack"; names[1] = "Mia";

  9. Array of Strings in C# - Delft Stack

    Oct 12, 2023 · In an array, we specify the type before declaring. So when we store string values in an array, it is called an array of strings. We must add a string type at the beginning to declare the array as a string. We must also write the square brackets [] and the string keyword. An example of how to declare a string array is below.

  10. How to Create an Array of Strings in C# - webdevtutor.net

    Jul 22, 2024 · To create an array of strings in C#, you can use the following syntax: string[] stringArray = new string[] { "Apple", "Banana", "Orange", "Grapes" }; In this example, we have initialized an array stringArray containing four strings: "Apple", "Banana", "Orange", and "Grapes".

  11. Some results have been removed
Refresh