I like to create an int[] with length X and value it with [0,1,2….X]
e.g.
public int[] CreateAA(int X){}
int[] AA = CreateAA(9) => [0,1,2,3,4,5,6,7,8,9]
is there any easy method? Or have to loop and init value
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can avail the functionality of IEnumerable.
This will create a IEnumerable List for you and
.ToArray()will satisfy your int array need.So for X=9 in your case it would generate the array for
[0,1,2,3,4,5,6,7,8,9](as you need)