Home All Groups Group Topic Archive Search About

convert string to string array

Author
7 Sep 2006 6:04 PM
kvicky
I have multiline textbox and I am trying to do a search functionality
based on the input entered in this Textbox. I am able to convert into a
string array if the search components are separated by commas, for ex
(Image1, Image2) by using the StringArrayConverter class available in
..Net 2.0. But I also want to convert the strings entered in new line
for example if I enter

Image1
Image2

I want to convert this into a string array too, I used the split
funtcion but it takes null value between two strings If I don't pass
any delimiter.

Can anybody please help me with this.

Thanks
K

Author
7 Sep 2006 6:16 PM
S Kachru
Try this...

string[] arr = s.Split(new char[] { '\n' });

where s is your string.

(I think split function takes in a character also, but my compiler is complaining...)


Show quoteHide quote
> I have multiline textbox and I am trying to do a search functionality
> based on the input entered in this Textbox. I am able to convert into
> a string array if the search components are separated by commas, for
> ex (Image1, Image2) by using the StringArrayConverter class available
> in .Net 2.0. But I also want to convert the strings entered in new
> line for example if I enter
>
> Image1
> Image2
> I want to convert this into a string array too, I used the split
> funtcion but it takes null value between two strings If I don't pass
> any delimiter.
>
> Can anybody please help me with this.
>
> Thanks
> K
Are all your drivers up to date? click for free checkup

Author
7 Sep 2006 7:03 PM
kvicky
Thanks...that worked and I used trim to remove the carriage return.

K

S Kachru wrote:
Show quoteHide quote
> Try this...
>
> string[] arr = s.Split(new char[] { '\n' });
>
> where s is your string.
>
> (I think split function takes in a character also, but my compiler is complaining...)
>
>
> > I have multiline textbox and I am trying to do a search functionality
> > based on the input entered in this Textbox. I am able to convert into
> > a string array if the search components are separated by commas, for
> > ex (Image1, Image2) by using the StringArrayConverter class available
> > in .Net 2.0. But I also want to convert the strings entered in new
> > line for example if I enter
> >
> > Image1
> > Image2
> > I want to convert this into a string array too, I used the split
> > funtcion but it takes null value between two strings If I don't pass
> > any delimiter.
> >
> > Can anybody please help me with this.
> >
> > Thanks
> > K
Author
7 Sep 2006 6:20 PM
Michael Nemtsev
Hello kvicky,

I don't think that is the good approach to look substring
I recommend u to read this http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/tree/browse_frm/thread/c6042f6ce5d418ab/3ba155249e87e5e0?rnum=1&_done=%2Fgroup%2Fmicrosoft.public.dotnet.languages.csharp%2Fbrowse_frm%2Fthread%2Fc6042f6ce5d418ab%2Feb5b783def1f282e%3F#doc_3ba155249e87e5e0

and see this http://groups.google.com/groups/search?q=dotnet+search+string

k> I have multiline textbox and I am trying to do a search functionality
k> based on the input entered in this Textbox. I am able to convert into
k> a string array if the search components are separated by commas, for
k> ex (Image1, Image2) by using the StringArrayConverter class available
k> in .Net 2.0. But I also want to convert the strings entered in new
k> line for example if I enter
k>
k> Image1
k> Image2
k> I want to convert this into a string array too, I used the split
k> funtcion but it takes null value between two strings If I don't pass
k> any delimiter.
k>
k> Can anybody please help me with this.
k>
k> Thanks
k> K
---
WBR,
Michael  Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Author
7 Sep 2006 7:04 PM
kvicky
Thanks

K

Michael Nemtsev wrote:
Show quoteHide quote
> Hello kvicky,
>
> I don't think that is the good approach to look substring
> I recommend u to read this http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/tree/browse_frm/thread/c6042f6ce5d418ab/3ba155249e87e5e0?rnum=1&_done=%2Fgroup%2Fmicrosoft.public.dotnet.languages.csharp%2Fbrowse_frm%2Fthread%2Fc6042f6ce5d418ab%2Feb5b783def1f282e%3F#doc_3ba155249e87e5e0
>
> and see this http://groups.google.com/groups/search?q=dotnet+search+string
>
> k> I have multiline textbox and I am trying to do a search functionality
> k> based on the input entered in this Textbox. I am able to convert into
> k> a string array if the search components are separated by commas, for
> k> ex (Image1, Image2) by using the StringArrayConverter class available
> k> in .Net 2.0. But I also want to convert the strings entered in new
> k> line for example if I enter
> k>
> k> Image1
> k> Image2
> k> I want to convert this into a string array too, I used the split
> k> funtcion but it takes null value between two strings If I don't pass
> k> any delimiter.
> k>
> k> Can anybody please help me with this.
> k>
> k> Thanks
> k> K
> ---
> WBR,
> Michael  Nemtsev :: blog: http://spaces.msn.com/laflour
>
> "At times one remains faithful to a cause only because its opponents do not
> cease to be insipid." (c) Friedrich Nietzsche
Author
8 Sep 2006 11:44 PM
Ben Voigt
"Michael Nemtsev" <nemt***@msn.com> wrote in message
news:1799a79b3aac218c8a0e2ea22157a@msnews.microsoft.com...
> Hello kvicky,
>
> I don't think that is the good approach to look substring
> I recommend u to read this
> http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/tree/browse_frm/thread/c6042f6ce5d418ab/3ba155249e87e5e0?rnum=1&_done=%2Fgroup%2Fmicrosoft.public.dotnet.languages.csharp%2Fbrowse_frm%2Fthread%2Fc6042f6ce5d418ab%2Feb5b783def1f282e%3F#doc_3ba155249e87e5e0
>
> and see this http://groups.google.com/groups/search?q=dotnet+search+string

None of the methods mentioned in these articles will have any advantage when
searching for a single character separator, in this case '\n'.
Author
9 Sep 2006 8:35 AM
Michael Nemtsev
Hello Ben,

there is description of how to search substrings, not the \n separator

Show quoteHide quote
BV> "Michael Nemtsev" <nemt***@msn.com> wrote in message
BV> news:1799a79b3aac218c8a0e2ea22157a@msnews.microsoft.com...
BV>
>> Hello kvicky,
>>
>> I don't think that is the good approach to look substring
>>
>> I recommend u to read this
>>
>> http://groups.google.com/group/microsoft.public.dotnet.languages.csha
>> rp/tree/browse_frm/thread/c6042f6ce5d418ab/3ba155249e87e5e0?rnum=1&_d
>> one=%2Fgroup%2Fmicrosoft.public.dotnet.languages.csharp%2Fbrowse_frm%
>> 2Fthread%2Fc6042f6ce5d418ab%2Feb5b783def1f282e%3F#doc_3ba155249e87e5e
>> 0
>>
>> and see this
>> http://groups.google.com/groups/search?q=dotnet+search+string
>>
BV> None of the methods mentioned in these articles will have any
BV> advantage when searching for a single character separator, in this
BV> case '\n'.
BV>
---
WBR,
Michael  Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

Bookmark and Share