Code Comments
Programming Forum and web based access to our favorite programming groups.Is there a good way to..... Get a comma delimited string like strBool = "false,true,false,false,true,false" split it into an array char[] chrsplit = ",".ToCharArray(); string[] myBoolArr = strBool.Split(chrsplit); and then turn this into a boolean array bool[] Thanks for any thoughts, Matt
Post Follow-up to this messageMattB wrote:
> Is there a good way to.....
>
> Get a comma delimited string like
> strBool = "false,true,false,false,true,false"
>
> split it into an array
>
> char[] chrsplit = ",".ToCharArray();
>
> string[] myBoolArr = strBool.Split(chrsplit);
>
> and then turn this into a boolean array bool[]
>
>
> Thanks for any thoughts,
> Matt
I looked through the Convert class and Array class, and did not see
anything for applying a method to all elements of an array. All I came
up with was the method:
public bool[] StringArrayToBool(String str)
{
String[] boolstringarray = str.Split(new char[]{','});
bool[] boolarray = new bool[boolstringarray.Length];
for(int x=0;x<boolstringarray.Length;x++)
boolarray[x]=Convert.ToBoolean(boolstringarray[x]);
return boolarray;
}
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.