Click here to Skip to main content
15,908,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a array and i want to convert that array in to sub arrays. the given below code is in python but i need it in c#.

Thank you.

What I have tried:

addresses = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"
                      ]
maxx = 6                       
q = 2
r = 4
for i in range(2):
  print(addresses[i * maxx: (i + 1) * maxx]) //['1', '2', '3', '4', '5', '6'] ['7', '8', '9', '10', '11', '12']



  
if r > 0:
    print (addresses[q * maxx: q * maxx + r]) //['13', '14', '15', '16']
Posted
Updated 18-Oct-19 8:27am

1 solution

See examples here: https://www.dotnetperls.com/2d[^]
string[,] array = new string[,]
        {
            {"cat", "dog"},
            {"bird", "fish"},
        };
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900