PC Review


Reply
Thread Tools Rate Thread

convertion from CollectionBase to string []

 
 
juli
Guest
Posts: n/a
 
      9th Jan 2005
I am trying to convert an object of a class which is derived from
collectionbase class.It's not working:
while ((line = file.ReadLine()) != null && line.IndexOf(" ")!=-1)
{
al.Add(line);


}
string[] exc_string = (string[])al.ToArray(typeof(string));

somebody know why?
Thank you!
 
Reply With Quote
 
 
 
 
Joakim Karlsson
Guest
Posts: n/a
 
      9th Jan 2005
Without a repro case and information about what it is that goes wrong
exactly it is hard to tell.

/Joakim

juli wrote:
> I am trying to convert an object of a class which is derived from
> collectionbase class.It's not working:
> while ((line = file.ReadLine()) != null && line.IndexOf(" ")!=-1)
> {
> al.Add(line);
>
>
> }
> string[] exc_string = (string[])al.ToArray(typeof(string));
>
> somebody know why?
> Thank you!

 
Reply With Quote
 
juli jul
Guest
Posts: n/a
 
      9th Jan 2005

ArrayList al = new ArrayList();
while ((line = file.ReadLine()) != null && line.IndexOf(" ")!=-1)
{
al.Add(line);


}
string[] exc_string = (string[])al.ToArray(typeof(string));

That's my program.Could u tell me why convertion faild?
Thanks!



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
juli jul
Guest
Posts: n/a
 
      9th Jan 2005

ArrayList al = new ArrayList();
while ((line = file.ReadLine()) != null && line.IndexOf(" ")!=-1)
{
al.Add(line);


}
string[] exc_string = (string[])al.ToArray(typeof(string));

That's my program.Could u tell me why convertion faild?
Thanks!



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Bob Grommes
Guest
Posts: n/a
 
      9th Jan 2005
"It's not working" is not a sufficient statement of the problem. What is
the exact error you're getting?

--Bob

"juli" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am trying to convert an object of a class which is derived from
> collectionbase class.It's not working:
> while ((line = file.ReadLine()) != null && line.IndexOf(" ")!=-1)
> {
> al.Add(line);
>
>
> }
> string[] exc_string = (string[])al.ToArray(typeof(string));
>
> somebody know why?
> Thank you!



 
Reply With Quote
 
Joakim Karlsson
Guest
Posts: n/a
 
      9th Jan 2005
Not without some more information I'm afraid. Could you

1. Describe what kind of failure you see. Do you get an exception? Get
corrupted data?

2. Could you post a short but complete program (as Jon likes to put it).

/Joakim

juli jul wrote:
> ArrayList al = new ArrayList();
> while ((line = file.ReadLine()) != null && line.IndexOf(" ")!=-1)
> {
> al.Add(line);
>
>
> }
> string[] exc_string = (string[])al.ToArray(typeof(string));
>
> That's my program.Could u tell me why convertion faild?
> Thanks!
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      9th Jan 2005
juli jul <(E-Mail Removed)> wrote:
>
> ArrayList al = new ArrayList();
> while ((line = file.ReadLine()) != null && line.IndexOf(" ")!=-1)
> {
> al.Add(line);
>
>
> }
> string[] exc_string = (string[])al.ToArray(typeof(string));
>
> That's my program.Could u tell me why convertion faild?


No, that's not your program. It's a small part of your program.Further,
as Joakim said, you haven't provided any sample data.

Please read http://www.pobox.com/~skeet/csharp/complete.html

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Ciaran
Guest
Posts: n/a
 
      10th Jan 2005
There isnt anything wrong with the code, Break on the line at the end of the
code snippet and check the contents of the ArrayList.

Ciaran

"juli jul" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
> ArrayList al = new ArrayList();
> while ((line = file.ReadLine()) != null && line.IndexOf(" ")!=-1)
> {
> al.Add(line);
>
>
> }
> string[] exc_string = (string[])al.ToArray(typeof(string));
>
> That's my program.Could u tell me why convertion faild?
> Thanks!
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
juli jul
Guest
Posts: n/a
 
      10th Jan 2005

Thank you all,but I found my problem.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
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
convertion naguaramipana Microsoft Access External Data 2 20th Nov 2008 06:22 AM
string convertion to date problem Rolo Microsoft Excel Programming 4 15th Dec 2005 03:51 PM
Convertion 2 melo Microsoft Excel Discussion 1 20th Jul 2005 10:17 AM
Re: convertion Duane Hookom Microsoft Access VBA Modules 0 8th Jun 2004 05:57 PM
String Convertion Problems Glenn Microsoft VC .NET 2 29th Apr 2004 03:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:49 AM.