PC Review


Reply
Thread Tools Rate Thread

convert string to string array

 
 
kvicky
Guest
Posts: n/a
 
      7th Sep 2006
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

 
Reply With Quote
 
 
 
 
S Kachru
Guest
Posts: n/a
 
      7th Sep 2006
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
>



 
Reply With Quote
 
Michael Nemtsev
Guest
Posts: n/a
 
      7th Sep 2006
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/micro...a155249e87e5e0

and see this http://groups.google.com/groups/sear...+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


 
Reply With Quote
 
kvicky
Guest
Posts: n/a
 
      7th Sep 2006
Thanks...that worked and I used trim to remove the carriage return.

K

S Kachru wrote:
> 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


 
Reply With Quote
 
kvicky
Guest
Posts: n/a
 
      7th Sep 2006
Thanks

K

Michael Nemtsev wrote:
> 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/micro...a155249e87e5e0
>
> and see this http://groups.google.com/groups/sear...+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


 
Reply With Quote
 
Ben Voigt
Guest
Posts: n/a
 
      9th Sep 2006

"Michael Nemtsev" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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/micro...a155249e87e5e0
>
> and see this http://groups.google.com/groups/sear...+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'.


 
Reply With Quote
 
Michael Nemtsev
Guest
Posts: n/a
 
      9th Sep 2006
Hello Ben,

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

BV> "Michael Nemtsev" <(E-Mail Removed)> wrote in message
BV> news:(E-Mail Removed)...
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/micro...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/sear...+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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert 'System.Collections.ObjectModel.ReadOnlyCollection(Of String)' to '1-dimensional array of String'. roidy Microsoft VB .NET 12 17th Jul 2009 10:53 AM
'System.String[]' from its string representation 'String[] Array' =?Utf-8?B?UmFqZXNoIHNvbmk=?= Microsoft ASP .NET 0 4th May 2006 05:29 PM
How to convert unmanaged string with char array type to managed string with char array type? joye Microsoft VC .NET 1 21st Jul 2005 09:32 AM
Convert string to a string array Andrew Banks Microsoft ASP .NET 2 19th Apr 2004 05:45 PM
Cannot create an object of type 'System.String[]' from its string representation 'String[] Array' for the 'Options' property. Hessam Microsoft C# .NET 0 8th Aug 2003 09:45 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:17 AM.