Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
so i wanted to play around with arrays in c# for learning purpose. but when i declare my array inside a method it gives the error } expected. here is my code
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace kwaterminal
{
    class RandomTerain
    {
        public static void generate()
        {
            public int[,] terain = new int[16, 16];

        }
    }
}


What I have tried:

i heave searched the web but i could not find a good answer
Posted
Updated 20-Jan-18 3:35am

1 solution

public[^] is an access modifier for types and type members - not for variables declared inside a method. Remove the public keyword and it will compile fine, and terain will be accessible anywhere inside the method (but not outside the method).
 
Share this answer
 
Comments
dolfijn3000 20-Jan-18 9:36am    
thank you for the answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900