String s = new String({'h','e','l','l','o'});
I received the error:
1 Invalid expression term '{'
I thought {'h','e','l','l','o'}
should be a character array, why did it fail to compile?
String s = new String({'h','e','l','l','o'});
I received the error:
1 Invalid expression term '{'
I thought {'h','e','l','l','o'}
should be a character array, why did it fail to compile?
I think you mean:
String s = new String(new[] {'h','e','l','l','o'});
The code you had before was not initializing an array correctly. Check out the MSDN article on implicitly typed arrays for more info.
You could also explicitly specify the type of the array:
String s = new String(new char[] {'h','e','l','l','o'});
Try something like this:
String s = new String(new char [] {'h','e','l','l','o'});