'how to convert this C# using RingCentral API to VB Net
I have an existing VB. Net application I am trying to add functionality to. The example code is in C# and I am not sure how to convert this section. I have converted the rest of it but stuck on this....
var parameters = new CreateSMSMessage();
parameters.from = new MessageStoreCallerInfoRequest { phoneNumber = "19998887777"};
parameters.to = new MessageStoreCallerInfoRequest[]
{
new MessageStoreCallerInfoRequest
{
phoneNumber = "12223334444"
} };
parameters.text = "Hello World from C#";
var resp = await restClient.Restapi().Account().Extension().Sms().Post(parameters);
Solution 1:[1]
I assume the part you're having trouble with is this:
parameters.from = new MessageStoreCallerInfoRequest { phoneNumber = "19998887777"};
parameters.to = new MessageStoreCallerInfoRequest[]
{
new MessageStoreCallerInfoRequest
{
phoneNumber = "12223334444"
}
};
VB has virtually identical array initializer syntax and slightly different member initializer syntax requiring the With
keyword and prepending .
on the member access.
The equivalent in VB is:
parameters.from = New MessageStoreCallerInfoRequest With {.phoneNumber = "19998887777"}
parameters.to = New MessageStoreCallerInfoRequest()
{
New MessageStoreCallerInfoRequest With {.phoneNumber = "12223334444"}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Craig |