0

I have char [] like {'Q','W','E','a','b','c','A','B','C'}

i want to put this char [] start from index 3 {'1',2','3'}

the result need to be {'Q','W','E','1',2','3''A','B','C'} how can i do that please?

thanks

4
  • 6
    What did you try? Commented Jun 20, 2017 at 17:51
  • 1
    Use a for loop. Commented Jun 20, 2017 at 17:51
  • 4
    this is not a char[], but a string[]. the concept is called splicing, there are many good posts, for example this one Commented Jun 20, 2017 at 17:53
  • 3
    Not to be nit-picky but your array examples are for strings not chars Commented Jun 20, 2017 at 17:53

1 Answer 1

3

It could be done using Linq as follows.

string[] Op1 = {"a","f","h","x","k","w","7"};
string[] Op2 = {"1",2","3"};
int StartIndex = 3;
string[] Result = Op1.Take(StartIndex).Concat(Op2).ToArray();
Sign up to request clarification or add additional context in comments.

1 Comment

sorry... i edit the post i need the rest of char after the concat

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.