- Home /
defining a C# built-in array on just one line
is it possible to do something like string[] s; s = ["apple","banana","canaple"];
on just one line, or must you define it explicitly on 3 different lines: s[0]="apple"; s[1]="banana"; s[2]="canaple";
Comment
Answer by liszto · Dec 21, 2012 at 10:35 AM
I think you can but I do this like this :
string[] s = {"apple","banana","canaple"};
Your answer
![](https://koobas.hobune.stream/wayback/20220613085743im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
What array-type does GetComponents return? 2 Answers
Syntax to initialize 2D (Jagged), built-in array at runtime 1 Answer
Distance error: Cannot cast from source type to destination 0 Answers
Can I change inspector 'Element 0' to something else? 6 Answers
Iterating a GO through an array of transform positions 0 Answers