-1

I have string values seperately and want them to insert into an array. For example

var Lin1="te1";
var Lin2="te2";

I want to insert this into an arry value and want them to use it by array index. ie. for array[0]="te1", array[1]="te2"..

How can we achieve this? Thanks in advance...

1

3 Answers 3

1

You can declare the contents of an array when you initialise it like so

string[] LinArray = new string[] { Lin1, Lin2 };
Sign up to request clarification or add additional context in comments.

Comments

0

You can use a List for this, if the number is not known beforehand.

 var list = new List<string>() { "te1", "te2"};
 list[0] = "te3";

Comments

0
string[] arr = new string[] {Lin1, Lin2};

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.