How can I define two dimensional dynamic array?
If I want to use List<>, can I use it for two dimensions?
How can I define two dimensional dynamic array? If I want to use List<>,
Share
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.
There’s no built-in dynamic equivalent of two-dimensional arrays that I’m aware of, but you can easily get at more or less the same functionaltiy.
Define a Coordinate class with this API:
You can now create a collection of these Coordinate instances.
If you create a
HashSet<Coordinate>you will be guaranteed that you cannot add a Coordinate if it’s already added because it overrides Equals.If you want, you can expand Coordinate to
Coordinate<T>like this:This will allow you to associate a strongly typed item with each coordinate, like this: