• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Dotnet Stuff

  • Home
  • Articles
  • Tutorials
  • Forums
  • Career Advice
  • Jobs
  • .NET FAQs
  • News
  • Privacy Policy

C# 3d array

In C# arrays can have multiple dimensions, arrays with more than one dimension. C# can support nearly 32 dimensions for multidimensional arrays.

To declare a multidimensional array, use commas between the square brackets to delimit the array’s dimensions. Arrays can be classified according to their dimensions.

The dimension of an array can be identified by counting the commas. The number of commas in a multidimensional array equals one less than the number of dimensions.  For example [,] is a 2D array, [, ,] is a 3D array, [, , ,] is a 4D array, so on and so forth.

C# 3D Array Examples

See the examples of C# 3D Array

//3D Array C#, Three-dimensional array in C#
int[, ,]  Csharp3dArray = new int[,,] { { { 20, 25, 30 }, { 30, 35, 40 } },
{ { 7, 8, 9 }, { 10, 11, 12 } } };
//C# 3d array with dimensions specified.
int[, ,] 3dArrayCsharp = new int[2,2,3] { { { 20, 25, 30 }, 
          { 30, 35, 40 } },{ { 7, 8, 9 }, { 10, 11, 12 } } };

More Examples of  C# 3d Arrays below..

C# 3d array with 1 row, 2-dimensional array [2,3]

int[, ,] 3darray1 = new int[1, 2, 3]{
{ { 4, 5,6}, { 3, 4,5} } };

C# 3d array with 2 row, 2 dimensional array [3,2]

int[, ,] 3darray2 = new int[2, 3, 2]{
{ {1, 2}, {3, 4} },
{ {5, 6}, {7, 8} },
{ {5, 6}, {7, 8} }
};

 

C# 3d array with 2 rows, 2-dimensional array [2,3]

int[, ,] 3darray3 = new int[2, 2, 3]{
{ { 1, 2, 3}, {4, 5, 6} },
{ { 7, 8, 9}, {10, 11, 12} }
};

C# 3d array with 3 rows of 2 diamensional array [3,3]

 

int[, ,] 3darray3 = new int[3, 3, 3]{
{ { 1, 2, 3}, {4, 5, 6}, {4, 5, 6}},
{ { 7, 8, 9}, {10, 11, 12}, {15, 16, 17}},
{ { 7, 8, 9}, {20, 21, 22},{30, 31, 32} }
};

 

The first rank gives the indication of the number of rows of the internal 2D arrays.

Summary

In this post, we explained C# 3d arrays and few examples. Hope this article was helpful for you. Please share your valuable feedback on 3d arrays in C# in the comments section

Related posts:

  1. JSON Tutorial – Learn JSON Quickly
  2. C# Fixed Size Buffer
  3. Static Classes in C# and Static Class Members In C#
  4. Check Whether Two Strings are Anagrams in C#

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Recent Topics

  • What is the Difference Between IEnumerable and IQueryable in C#
  • How to remove Header of the XML file in C#?
  • What is DBMS?
  • What is RDBMS?
  • What is asp net framework ?
Log In
Increase Your Leadership Skills, Influence, and Power with Top Leadership courses starting at just $11.99.

Recent Posts

  • .NET Core Version History | Release History of .NET Core
  • What is string interpolation in C#
  • What Is The Use Of Volatile Keyword In C#
  • Get System IP Address Using C#
  • SQL Server Interview Question and Answers
  • C# Fixed Size Buffer
  • OWIN in ASP.NET Core| What is OWIN in .NET?
  • C# Version History | C# Evolution and Features
  • What is ASP.NET Core Module
  • C# 3d array

Recent Forum Topics

  • What is the Difference Between IEnumerable and IQueryable in C#
  • How to remove Header of the XML file in C#?
  • What is DBMS?
  • What is RDBMS?
  • What is asp net framework ?

Forums

  • .NET Framework
  • ASP.NET
  • C#
  • SQL

Recent Topics

  • What is the Difference Between IEnumerable and IQueryable in C#
  • How to remove Header of the XML file in C#?
  • What is DBMS?
  • What is RDBMS?
  • What is asp net framework ?

© Copywright 2017 Dotnetstuffs All Rights Reserved