?
Solved

How can I declare dynamic  two dimensional Array in Csharp?

Posted on 2016-08-17
4
Medium Priority
?
42 Views
Last Modified: 2016-09-05
How can I define two dimensional dynamic array? ,i'm Writing Dijkstra Algorithm program,i wanna each node that connected to another nodes  its value save into array.in fact , it should be dynamic two dimensional Array.not specified which one of nodes connected to another nodes.picture
0
Comment
Question by:Member_2_7970207
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 664 total points (awarded by participants)
ID: 41759795
This isn't what you asked for but maybe a list of 2-tuples might be useful:
https://msdn.microsoft.com/en-us/library/dd268536(v=vs.110).aspx
0
 
LVL 35

Accepted Solution

by:
sarabande earned 668 total points (awarded by participants)
ID: 41759856
if you know the dimensions bevor you do it by this (somehow weird) syntax:

int [, ] array2d = new int [4, 2];

Open in new window


if not you may use a List

List< List<Node> > array2d = new List< List<Node> > ;
array2d.Add(new List<Node>);

array2d[0].Add(new Node(7, 53));

Open in new window


(i hope the syntax is correct).

Sara
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 668 total points (awarded by participants)
ID: 41759868
I don't think you'll want sarabande's array syntax. That defines a square array, which means both dimensions are fixed to what you declare them as. You probably want an array of arrays. It's somewhat related to a square array, but the only the first dimension is fixed--the 2nd dimension is dynamic:

int[][] array2d = new int[5][];

It's similar, in effect, to the list of lists that sarabande purposes.
0
 
LVL 35

Expert Comment

by:sarabande
ID: 41784464
Closed with an equal share of points.

Sara
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question