By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,709 Members | 2,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,709 IT Pros & Developers. It's quick & easy.

convertion from CollectionBase to string []

P: n/a
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!
Nov 16 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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!

Nov 16 '05 #2

P: n/a

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!
Nov 16 '05 #3

P: n/a

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!
Nov 16 '05 #4

P: n/a
"It's not working" is not a sufficient statement of the problem. What is
the exact error you're getting?

--Bob

"juli" <ji****@gmail.com> wrote in message
news:1f*************************@posting.google.co m...
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!

Nov 16 '05 #5

P: n/a
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!

Nov 16 '05 #6

P: n/a
juli jul <ju******@yahoo.com> 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 - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #7

P: n/a
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" <ju******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...

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!

Nov 16 '05 #8

P: n/a

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!
Nov 16 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.