[英]Error when converting C# to VB.NET in my windows phone project
I have been trying to convert some c# code to VB.NET for a while now. 我一直试图将一些c#代码转换为VB.NET一段时间。 The purpose of this is that i am trying to build some kind of Twitter client, i have nearly converted all fo the following code for a class within my project, which is currently: 这样做的目的是我正在尝试构建某种类型的Twitter客户端,我几乎已经为我的项目中的一个类转换了以下代码,目前:
Friend Shared Function GetRequestTokenQuery() As OAuthWebQuery
Dim oauth = New OAuthWorkflow() With { _
Key .ConsumerKey = AppSettings.consumerKey, _
Key .ConsumerSecret = AppSettings.consumerKeySecret, _
Key .SignatureMethod = OAuthSignatureMethod.HmacSha1, _
Key .ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, _
Key .RequestTokenUrl = AppSettings.RequestTokenUri, _
Key .Version = AppSettings.oAuthVersion, _
Key .CallbackUrl = AppSettings.CallbackUri _
}
Dim info = oauth.BuildRequestTokenInfo(WebMethod.[Get])
Dim objOAuthWebQuery = New OAuthWebQuery(info, False)
objOAuthWebQuery.HasElevatedPermissions = True
objOAuthWebQuery.SilverlightUserAgentHeader = "Hammock"
Return objOAuthWebQuery
End Function
However i then get the error 'Name of field or property being initialized in an object initializer must start with '.'' with the first mention of 'key' underlined in blue. 然而,我得到错误'在对象初始化程序中初始化的字段或属性的名称必须以'。''开头,首先提到以蓝色下划线的'key'。 Anyone got any ideas as to how i need to change my code? 任何人都有任何想法,我需要如何更改我的代码?
The Correct syntax in VB.net would be like this VB.net中的正确语法就是这样
Friend Shared Function GetRequestTokenQuery() As OAuthWebQuery
Dim oauth = New OAuthWorkflow() With { _
.ConsumerKey = AppSettings.consumerKey, _
.ConsumerSecret = AppSettings.consumerKeySecret, _
.SignatureMethod = OAuthSignatureMethod.HmacSha1, _
.ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, _
.RequestTokenUrl = AppSettings.RequestTokenUri, _
.Version = AppSettings.oAuthVersion, _
.CallbackUrl = AppSettings.CallbackUri _
}
Dim info = oauth.BuildRequestTokenInfo(WebMethod.[Get])
Dim objOAuthWebQuery = New OAuthWebQuery(info, False)
objOAuthWebQuery.HasElevatedPermissions = True
objOAuthWebQuery.SilverlightUserAgentHeader = "Hammock"
Return objOAuthWebQuery
End Function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.