- Home /
What Does [,] means? Class Constructor
Im following a tutorial in youtube and i noticed something,what does [,] means?
The class constructor :
using UnityEngine;
using System.Collections;
public class Node {
public Vector3 worldpoint;
public bool walkable;
public Node parent;
public int hcost,gcost;
public int gridX,gridY;
public Node(Vector3 _worldpoint,bool _walkable,int _gridX,int _gridY)
{
worldpoint = _worldpoint;
walkable = _walkable;
gridX = _gridX;
gridY = _gridY;
}
public int fCost
{
get
{
return hcost + gcost;
}
}
}
The using of the class constructor :
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Grid : MonoBehaviour {
Node[,] grid;
}
Answer by Landern · Apr 02, 2015 at 01:37 PM
It's a multidimensional array. You can think of it like a grid in this case. If the grid was initialized as:
Node[,] grid = new Node[10, 5];
The grid would be 10 by 5.
check out the MSDN documentation on arrays:
Is one of the uses like this? use a list, the X size,the Y size for loop through all the size then add them to the list 2 dimesionally so that it can find its specific number in the list?
Answer by steakpinball · Apr 02, 2015 at 01:40 PM
It means multidimensional array. Also known as a matrix.
https://msdn.microsoft.com/en-us/library/2yd9wwz4.aspx
The case in your description creates an array of two dimensions. Every row will have the same number of columns. As opposed to a jagged array, Node[][] grid
, which could have a different number of columns in each row.
Your answer
![](https://koobas.hobune.stream/wayback/20220613191932im_/https://answers.unity.com/themes/thub/images/avi.jpg)