简体   繁体   English

vb.net和C#编码的编码差异

[英]Difference of coding in vb.net and C# issue

Guys I am working with an API integration project in vb.net. 伙计我正在使用vb.net中的API集成项目。 Result from API is returned in XML format and I have been provided with some some of the classes which help me to navigate through xml. API的结果以XML格式返回,我已经提供了一些帮助我浏览xml的类。 It's one of the class is WSGetFareQuoteRequest which has many properties. 它的一个类是WSGetFareQuoteRequest ,它有许多属性。 And one of its properties is Result which is defined in the integration document as: 其中一个属性是Result ,它在集成文档中定义为:

Response Description 响应说明

Structure of WSGetFareQuoteResponse is as follows: WSGetFareQuoteResponse结构如下:

Field Name                      DataType                       Remarks 
Result*                         WSResult                       This        result       will 
                                                                comprise   of   the   new 
                                                                fare(if      any    of    the 
                                                                component        of      fare 
                                                               gets               updated), 
                                                               otherwise         it     will 
                                                                remain the same. 

Status                          WSStatus                        It will be having the 
                                                                status         or      error 
                                                                information. 

When I asked API team regarding the initialisation of this result property of this object they provided me c# code as shown below : 当我向API团队询问有关此对象的此结果属性的初始化时,他们为我提供了c#代码,如下所示:

WSGetFareQuoteRequest wsFareQuoteRequest = new WSGetFareQuoteRequest();

WSGetFareQuoteResponse wsFareQuoteResponse = new WSGetFareQuoteResponse();

int nor = 1;

if (searchResponse.Result != null && searchResponse.Result.Length    0 && 
   objResult[i].IsLcc)

   {

   wsFareQuoteRequest.Result = new WSResult[nor];

   wsFareQuoteRequest.Result[0] = new WSResult();

   wsFareQuoteRequest.Result[0] = objResult[i];

   wsFareQuoteRequest.SessionId = searchResponse.SessionId;

   wsFareQuoteResponse = bApi.GetFareQuote(wsFareQuoteRequest);

Now my question is that I am doing the project in vb.net.I tried its vb.net equivalent it is showing me error at first line of object creation of Result property.I tried its vb.net equivalent as: 现在我的问题是我在vb.net中做项目。我尝试了它的vb.net等效它在Result属性的对象创建的第一行显示错误。我尝试了它的vb.net等效为:

wsFareQuoteRequest.Result = New WSResult(nor) 
'Only above line is creating error as Too many arguments to Pub Sub New'
            wsFareQuoteRequest.Result(0) = New WSResult()
            wsFareQuoteRequest.Result(0) = searchresponse.Result(i)
            wsFareQuoteRequest.SessionId = searchresponse.SessionId
            wsFareQuoteResponse = bapi.GetFareQuote(wsFareQuoteRequest)

Arrays in Visual Basic > Creating an Array Visual Basic中的数组>创建数组

cargoWeights = New Double(10) {}
atmospherePressures = New Short(2, 2, 4, 10) {}
inquiriesByYearMonthDay = New Byte(20)()() {}

and in your case it would be: 在你的情况下,它将是:

wsFareQuoteRequest.Result = New WSResult(nor) {}

you are missing the {} at the end. 你最后错过了{}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM