CipherIS
asked on
.NET 2008 VB and C#
I created a list in VB
VB
Any idea how I can copy from one to other?
VB
Namespace Models
Public NonInheritable Class MyLIst
Public id as Integer
..........
End Class
End Namespace
C#
namespace otherproj.Models
{
public class MyListCopy
{
public int32 id = 0;
.....
}
]
So, my vb code uses the model in my C# code. I am trying to add the values from my vb model to my c# model. It is giving me an error index out of range. Private myList As List(Of Models.MyList) = Singleton.mylist
Dim myList2 As New List(Of OtherProj.Models.MyList2)
private sub SetSendlistvalues(ByRef myList2 As List(Of OtherProj.Models.MyList2))
myList2(0).id = myList(0).id
.......
end sub
Any idea how I can copy from one to other?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If I understand correctly that is nothing to do with a VB.net/C# problem. You would experience exactly the same if you tried to do both classes in VB.NET. (You did not add any items into the second list).
ASKER
Yes. What is ironic was that it was working without the add by copying the values over. Then it stopped working.
Just an aside. I hope you know that both VB.NET and C# compile to identical intermediate code and are compatible with one another. So a class developed in VB.NET can be used in C# - no requirement to duplicate it, just have it in a dll and use the VB.NET dll directly from your C# app.
ASKER
Yes, I'm aware of that. I needed to pass the list as a parameter which gets picked up in C#. I'm making modifications to an app. If I had the time I would implement it.
ASKER