C # to vb Initiating a transform object

I have been trying to pick up VB.net and program in C # for a while now. I grabbed most of vb.net but ran into some problems with this conversion to initialize an object:

CustomerParameters customerParameters = new CustomerParameters
                                               {
                                                   FirstName = "C First Name",
                                                   LastName = "C Last Name"
                                               };

      

Any thoughts on how to do this in VB, or if it's possible?

+1


a source to share


2 answers


Dim cp As New CustomerParameters() With { _
     .FirstName = "C First Name", _
     .LastName = "C Last Name" _
}

      



+4


a source


I cannot test it here because the syntax requires VS2008 and I only have VS2005. But in VB.Net, you need to use the With

initialization keyword .

Dim c As New CustomerParameters() With { _
    .FirstName = "C First Name", _
    .LastName = "C Last Name" _
}

      



Yes, it's right. Curly curly braces in VB.

+1


a source







All Articles