Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# How can I declare dynamic  two dimensional Array in Csharp?

Posted on 2016-08-17
Medium Priority
46 Views
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.
0
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
• 2

LVL 45

Assisted Solution

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

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];
``````

if not you may use a List

``````List< List<Node> > array2d = new List< List<Node> > ;

``````

(i hope the syntax is correct).

Sara
0

LVL 75

Assisted Solution

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

ID: 41784464
Closed with an equal share of points.

Sara
0

## Featured Post

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
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…
###### Suggested Courses
Course of the Month9 days, 1 hour left to enroll