Implicit conversion of an array

G

Guest

Given:
Class Data
{
Public Data (string[] vals) { /*Fills properties*/ }
}

public Data[] ParseFile (StreamReader input)
{
ArrayList list = new ArrayList();
string line = input.ReadLine();
while (line!=null)
{
list.Add (new Data (line.Split ('|')));
}

Is there a way to declare an implicit conversion such that

return list.ToArray();

Works?

}

TIA,
Dave
 
D

Daniel O'Connell [C# MVP]

Dave said:
Given:
Class Data
{
Public Data (string[] vals) { /*Fills properties*/ }
}

public Data[] ParseFile (StreamReader input)
{
ArrayList list = new ArrayList();
string line = input.ReadLine();
while (line!=null)
{
list.Add (new Data (line.Split ('|')));
}

Is there a way to declare an implicit conversion such that

return list.ToArray();

Works?

Don't think so. Why not just cast?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top