How do I convert "string lol = "112233aabb cc"; int num = string[0];"
C# to VB.NET
Collapse
X
-
Tags: None
-
First and foremost that code will cause errors, simply because lol is a string not an array so you cannot access it the way you are in num. What you would have to do is make make lol into a string array, like this
You next problem is the item at index 0 is a string not an int so that would make your code puke. You need to convert it to an int first, like this:Code:string lol = "112233aabbcc"; string[] array = lol.Split(new char[] {','});
So now we have working C# code, now we can convert it to VB.NET:Code:int temp = 0; if(int.TryParse(array[0], out temp)) { int num = temp; }
NOTE: This was written in notepad because I have no IDE open so it's just a sample of what you're looking for and this should give you a good startCode:Dim lol As String = "112233aabbcc" Dim array As String() = lol.Split(New Char() {","C}) Dim temp As Integer = 0 Dim num As Integer If Integer.TryParse(array(0), temp) Then num = temp End If -
Go to google, search "Convert C# to VB". The very first site is:http://www.developerfusion.com/tools.../csharp-to-vb/ Simply paste your C# in and press Convert. It's a very good tool, and haven't let me down yet.Comment
Comment