conversion from java to c#

G

Guest

I am working with a project which converts a java based application into C#. I noticed that when I converted the java file, .net throws a SupportClass for me and since there is no List type in C#, SupportClass tries to use ListCollectionSupport instead. This is working great, except one situation, I got runtime error "Specified cast is not valid", and I am sure the following code caused this error
[Serializable
sealed public class WebOrder : System.Runtime.Serialization.ISerializabl

internal SupportClass.ListCollectionSupport orderItemsList
public EcomWeb.domain.OrderItem[] OrderItem
{
ge

return (EcomWeb.domain.OrderItem[]) orderItemsList.ToArray(ne
EcomWeb.domain.OrderItem[0])

}
public WebOrder():base(

//UPGRADE_ISSUE: Class hierarchy differences between 'java.util.ArrayList'
//'System.Collections.ArrayList' may cause compilation errors
//'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1186"
orderItemsList = new SupportClass.ListCollectionSupport(new System.Collections.ArrayList())


In my original java code, ListCollectionSupport is Java.Util.List type, OrderItem is an abstract Class, both rxItem and octItem are derived from this abstract class
I realy appreciate any reply on this issue and would like to supply anny more information if asked for
Thanks
Daniel
 
J

Jon Skeet [C# MVP]

daniel said:
I am working with a project which converts a java based application
into C#. I noticed that when I converted the java file, .net throws a
SupportClass for me and since there is no List type in C#,
SupportClass tries to use ListCollectionSupport instead. This is
working great, except one situation, I got runtime error "Specified
cast is not valid", and I am sure the following code caused this
error.

return (EcomWeb.domain.OrderItem[]) orderItemsList.ToArray(new
EcomWeb.domain.OrderItem[0]);

<snip>

It looks like this is a bug in the converter. I believe this should
actually be:

return (EcomWeb.domain.OrderItem[]) orderItemsList.ToArray
(typeof(EcomWeb.domain.OrderItem));
 

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