Link to home
Start Free TrialLog in
Avatar of CipherIS
CipherISFlag for United States of America

asked on

.NET 2008 VB and C#

I created a list in VB

VB
Namespace Models
Public NonInheritable Class MyLIst
   Public id as Integer
    ..........
End Class
End Namespace

Open in new window

C#
namespace otherproj.Models
{
public class MyListCopy
{
    public int32 id = 0;
    .....
}
]

Open in new window

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

Open in new window


Any idea how I can copy from one to other?
ASKER CERTIFIED SOLUTION
Avatar of CipherIS
CipherIS
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CipherIS

ASKER

Figured it out
Avatar of AndyAinscow
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).
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.
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.