| Quick Search |
First, here we observe that there are some ways to declare and instantiate a string[] array local variable. They are all equivalent in the compiled code [see note], so choose the one you think is clearest to read.
~~~ Program that initializes string arrays (C#) ~~~
class Program
{
static void Main()
{
// String arrays with 3 elements:
string[] arr1 = new string[] { "one", "two", "three" }; // A
string[] arr2 = { "one", "two", "three" }; // B
string arr3 = new string[] { "one", "two", "three" }; // C
string[] arr4 = new string[3]; // D
arr4[0] = "one";
arr4[1] = "two";
arr4[2] = "three";
}
}
Description. The above Main function shows four string[] arrays, each equal to the compiler. The biggest difference is that the first three arrays are declared on one line, while the fourth array is assigned in separate statements. The fourth array would permit you to test each value or insert logic as you assign it.
Posted in ASP.NET
You can follow any responses to this entry through the RSS 2.0 Feed. You can leave a response , or trackback from your own site.
search engine marketing company India that offers affordable seo services