473,386 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

convertion from CollectionBase to string []

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
8 3165
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

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

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
"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
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
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
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: m. pollack | last post by:
Hi all, I've been using the CollectionBase class to implement a strongly-typed collection, but I have noticed that the RemoveAt method does not seem to call the "On" hook methods (OnRemove,...
0
by: Mike Pollett | last post by:
Hi, I have used the ISerializable interface before and the code below worked fine. Until I derived it from CollectionBase. The code will still serialize and deserialize the properties in this class...
1
by: Mike Pollett | last post by:
Hi, I have used the ISerializable interface before and the code below worked fine. Until I derived it from CollectionBase. The code will still serialize and deserialize the properties in this class...
2
by: wael radwan | last post by:
how to customize the serialization of a collection that inherited form CollectionBase i.e making the class implementing ISerializable interface because when deserializing using the desrializing...
1
by: Morten Dyndgaard | last post by:
Hi, I want to do the following: I have to XmlSerialize a HashTable, but since it inherits from IDictionary it cannot be XmlSerialized, and I prefer not to make my own implementation of...
1
by: Web Team | last post by:
Hi All, I'm trying to build a webservice that returns a CollectionBase. I am getting this error: "You must implement a default accessor on System.Collections.CollectionBase because it...
4
by: Kejpa | last post by:
Hi, I've begun trying out the .NET2005 beta and one thing that I was thrilled about in advance was the CollectionBase class. No more selfmade Collection classes I thought. But now I'm puzzled, I...
3
by: myPosts | last post by:
Hi all, I am having class which is derived from collectionbase class. I am adding some string elements to this collection. What i want is to add support of hashing into class which i have...
0
by: LIJO CHEERAN | last post by:
Hello friends I am trying to study about CollectionBase. I have inherited CollectionBase in the class TheCollection.cs. I am using the “TheCollection. in an aspx page to store objects...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.