Prakash Prakash - 1 year ago 172
C# Question

How To convert 1D array to 2D array in C#

I have:

string snacks="Chocolate,Alwa,Samosa,Channa";

I need this as array like:

snacks= {"Chocolate,Alwa" , "Samosa,Channa"};
in C#.

Could anyone pls Suggest the way to find my snacks

Answer Source
        string snack2[][]=new string[Math.Round(snacks.Length/2)][2];
        int cnt=0;
        for(int i=0;i<Math.Round(snacks.Length/2);i++)
             for (int j=0;j<2;j++)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download