Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将C#转换为VB。正在挣扎(数组:new[]和关键字Await)_C#_Vb.net_Visual Studio 2010 - Fatal编程技术网

将C#转换为VB。正在挣扎(数组:new[]和关键字Await)

将C#转换为VB。正在挣扎(数组:new[]和关键字Await),c#,vb.net,visual-studio-2010,C#,Vb.net,Visual Studio 2010,我正在努力将下面的代码转换为VB C#: VB: 我不得不扔掉等待,我就是无法让数组正常工作(),因为()有一条蓝线,上面写着预期输入。这是通过New() 请注意,我了解以下转换工具: 这些对数组new()和关键字wait没有帮助,我已经累了。试试这个: Dim credential As UserCredential Using stream = New FileStream(client_Secrets, FileMode.Open, FileAccess.Read) creden

我正在努力将下面的代码转换为VB

C#:

VB:

我不得不扔掉等待,我就是无法让数组正常工作(),因为()有一条蓝线,上面写着预期输入。这是通过New()

请注意,我了解以下转换工具:

这些对
数组new()
和关键字wait没有帮助,我已经累了。

试试这个:

Dim credential As UserCredential
Using stream = New FileStream(client_Secrets, FileMode.Open, FileAccess.Read)
    credential = Await GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, New () {YouTubeService.Scope.YoutubeUpload}, "user", CancellationToken.None)
End Using

VB等价物如下所示-没有“New()”:

我不明白你为什么要省略“等待”。你能解释一下吗?

Dim scopes As IList(Of String)=新列表(Of String)()


这将起作用,因为我从谷歌获得了它,并根据我的需要调整它

@DmitryLedentsov如果它是我遇到问题的数组,代码转换器将不会有帮助我已经完成了转换,它只是数组和等待关键字,我不确定关于
新对象(){YouTubeService.Scope.YoutubeReadonly}的VB等价性
?@Bjørn RogerKringsjå我尝试了新对象,但出现了以下错误:“System.Threading.Tasks.Task(Google.api.Auth.OAuth2.UserCredential)类型的值”我正在从事Visual studio 2010和一个非常古老的项目。根据下面的答案,这可以解释等待问题。等待关键字在VB中不存在,您还添加了new(),这也是不起作用的地方。@Pomster-await确实存在。请看这里:@Pomster-如果编译器告诉您没有,那么您一定是针对较旧版本的.NET frameworkexist@Pomster:一个旧版本的VB-“wait”只在VS 2012(VB 11?)中成为语言。@Pomster-请删除我的否决票。您在原始问题中没有提到您使用的是较旧版本的Visual Studio。这是我在插入wait时遇到的错误。”未声明“等待”。由于它的保护级别,它可能无法访问。@Pomster:我明白了-您使用的是2012年以前的某个版本的VB。
Using stream = New FileStream(client_Secrets, FileMode.Open, FileAccess.Read)
    credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, 
             New () {YouTubeService.Scope.YoutubeReadonly}, "user", CancellationToken.None, New FileDataStore(Me.[GetType]().ToString()))
End Using
Dim credential As UserCredential
Using stream = New FileStream(client_Secrets, FileMode.Open, FileAccess.Read)
    credential = Await GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, New () {YouTubeService.Scope.YoutubeUpload}, "user", CancellationToken.None)
End Using
Using stream = New FileStream(client_Secrets, FileMode.Open, FileAccess.Read)
  credential = Await GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, { YouTubeService.Scope.YoutubeUpload }, "user", CancellationToken.None)
End Using
    scopes.Add(Google.Apis.YouTube.v3.YouTubeService.Scope.YoutubeReadonly)

    Dim credential As UserCredential
    Using stream = New FileStream("client_secret.json", FileMode.Open, FileAccess.Read)
        credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream).Secrets, scopes, "user", CancellationToken.None,
                New FileDataStore("YouTubeService.VB.Sample")).Result
    End Using