views:

93

answers:

2

Hey, I wonder how all this is in VB.NET

In C#

UserSettings vUsers = new UserSettings();
UserSettings.IUserSettings vUserI = (UserSettings.IUserSettings)vUsers


I took a chance to try to write it in VB.NET, but is this right?

In VB.NET

Dim vUsers As UserSettings = New UserSettings()
Dim vUserI As UserSettings.IUserSettings = (UserSettings.IUserSettings)vUsers
+2  A: 

it will be written in vb.Net as:

Dim vUsers As New UserSettings()
Dim vUserI As UserSettings.IUserSettings = DirectCast(vUsers, UserSettings.IUserSettings)

Further, you can try this for any C# to VB.Net conversion:

http://www.developerfusion.com/tools/convert/csharp-to-vb/

Hope this Helps!!

viky
Where time we began to use ";" in VB.NET? : S
sv88erik
sorry, Updated my answer for that!!
viky
Instead of `DirectCast` you might also stumble upon `CType(vUsers,UserSettings.IUserSettings)`. The two are similar, but don't do exactly the same thing. Most of the time you want to use DirectCast though (like in this case). For further explanation read http://www.codeproject.com/KB/vb/DirectcastVsCtype.aspx
0xA3
+2  A: 

You are casting directly in c#, so I should think DirectCast would be the method to use here.

Dim vUsers As New UserSettings()

Dim vUserI As UserSettings.IUserSettings = DirectCast(vUsers, UserSettings.IUserSettings)
nealkernohan
Thanks for such a dikrete answers to my questions!
sv88erik