0

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
  • It doesn't seem to be right, or you wouldn't ask, right? ;) Commented Dec 22, 2009 at 9:44
  • Thus, VS gives it no direct fault ... (UserSettings.IUserSettings) vUsers doubt I stretched on the written as in VB.NET Commented Dec 22, 2009 at 9:47

2 Answers 2

2

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)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for such a dikrete answers to my questions!
2

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!!

3 Comments

Where time we began to use ";" in VB.NET? : S
sorry, Updated my answer for that!!
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 codeproject.com/KB/vb/DirectcastVsCtype.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.