Archive for April 22nd, 2009
Char Array to String in VB.NET 2.0
Written by Zealus on April 22, 2009 – 3:29 pm -You will be surprised, but the obvious
Dim arrChars(10) As Char Dim strString As String strString = "ABCDEFGHIK" arrChars = strString.ToCharArray strString = arrChars.ToString
Will not yield the same string as there was before. It will, rather, return “Char[]” response. To get your string back from Char Array (at least in VB.NET 2.0) you will need to call CStr on array:
Dim arrChars(10) As Char Dim strString As String strString = "ABCDEFGHIK" arrChars = strString.ToCharArray strString = Cstr(arrChars)
Funny, isn’t it? And totally counter-intuitive
Tags: .net, microsoft, programming, vb.net
Posted in annoyances, programming | 2 Comments »