0

Find the error!

class Program { static void Main(string[] arrgs) { int k = 2,l=6; int n = new int[10]; for(int i=0;i< n.Length;i++){ n[i] = l*2+i Console.WriteLine(n[i]); } } }

6th Mar 2019, 4:22 PM
Narushipudenn
Narushipudenn - avatar
4 Answers
+ 1
First error: int [] n = new int[10]; You need to look at the error message in the error window: Error CS0029 Cannot implicitly convert type 'int[]' to 'int'. Meaning the type of the left side doesn't match the type of the right. Check what type you want, and than check the spelling that matches with that type, on for instance msdn, and compare that with what you've written and find your spelling errors (a lot of errors are spelling, or brackets, ...).
6th Mar 2019, 6:31 PM
[No Name]
0
Third error. { n[i] = l * 2 + i; Console.WriteLine(n[i]); Semi-colon after the n[i] = l * 2 + i In your error list it says: Error CS1002 ; expected.
6th Mar 2019, 6:39 PM
[No Name]
0
Fourth error: Visual studio helps a lot with debugging. Use the error window. This is your main, key error. You can't code if you can't debug.
6th Mar 2019, 6:42 PM
[No Name]
- 1
Second "error", especially since you're posting, is not an error but a general practice, give meaningful names. Especially if you're sharing your code with others for review. "n" is not a good name for on int array.
6th Mar 2019, 6:38 PM
[No Name]