Newbie still learning, been trying to search and hack code together for hours now, I think there’s something fundamental I’m not getting!
Okay so,I have a string (taken from a text file) – “user1,password,1,0;user2,password,0,0;user3,password,0,0;user4,password,0,0”
I want to split the string into a multidimensional array(I think)
userAccount[1]=
accountDetails[userName]=user1
accountDetails[password]=password
accountDetails[adminRights]=1
accountDetails[loginAttempts]=0
userAccount[2]=
accountDetails[userName]=user2
...So on and so on
I’d like to use an enum for accountDetails for readability aswell but I can get that working after.
What is the best way of creating this multidimensional array from the string?
Lots thanks in advance,
Ross
As others suggested, creating a class for the data would be a better choice than a multidimensional “array”.
The class could look like this:
And you could then parse the string using
string.Split()first for;and then in each part for,. Using LINQ it could look like this: