在VB.NET中编写C#代码

时间:2015-08-15 06:37:11

标签: c# vb.net

我想在VB.NET中编写这段代码:

ModernIpg.PaymentWebServiceService ModernService = new ModernIpg.PaymentWebServiceService();
ModernService.AllowAutoRedirect = true;
ModernIpg.loginRequest req = new ModernIpg.loginRequest();
req.username = username;
req.password = password;

string Session_ID = ModernService.login(req);

ModernIpg.wsContext context = new ModernIpg.wsContext() { data = new ModernIpg.wsContextEntry[1] };
context.data[0] = new ModernIpg.wsContextEntry();
context.data[0].key = "SESSION_ID";
context.data[0].value = Session_ID;

我怎么做?

1 个答案:

答案 0 :(得分:0)

试试这个

        Dim ModernService As New ModernIpg.PaymentWebServiceService()
        ModernService.AllowAutoRedirect = True
        Dim req As ModernIpg.loginRequest = New ModernIpg.loginRequest()
        req.username = username
        req.password = password

        Dim Session_ID As String = ModernService.login(req)

        Dim context As ModernIpg.wsContext = new ModernIpg.wsContext() { data = new ModernIpg.wsContextEntry(1) }
        context.data(0) = New ModernIpg.wsContextEntry()
        context.data(0).key = "SESSION_ID"
        context.data(0).value = Session_ID​

代码看起来应该是这样的

Module Module1

    Sub Main()
        Dim context As ModernIpg.wsContext = New ModernIpg.wsContext() With {.data = New ModernIpg.wsContextEntry(1)}

    End Sub

End Module
Public Class ModernIpg
    Public Class wsContext
        Public data As wsContextEntry
    End Class
    Public Class wsContextEntry
        Sub New(x As Integer)

        End Sub
    End Class
End Class​