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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think you mean:
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: