I need to hard code an array of points in my C# program. The C-style initializer did not work.
PointF[] points = new PointF{ /* what goes here? */ };
How is it done?
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.
Like this:
In c# 3.0 you can write it even shorter:
update Guffa pointed out that I was to short with the
var points, it’s indeed not possible to ‘implicitly typed variable with an array initializer’.