meestuf.com
-----------------------------------------------------------------------------------------------------
1. Create a new console project.
2. Edit the Program.cs inside static void Main(string[] args) file as shown below.
static void Main(string[] args)
{ int[,] multiplicationTable = new int[11,11]; for (int i = 1; i < 11; i++) for (int x = 1; x < 11; x++) multiplicationTable[i, x] = i * x; Console.Write("x".PadRight(3) + "|"); for (int i = 1; i < 11; i++) { Console.Write(i.ToString().PadRight(3) + "|"); } Console.Write("\n"); Console.WriteLine("--------------------------------------------"); for (int i = 1; i < 11; i++) { Console.Write(i.ToString().PadRight(3) + "|"); for (int x = 1; x < 11; x++) { Console.Write(multiplicationTable[i, x].ToString().PadRight(3) + "|"); } Console.Write("\n"); Console.WriteLine("--------------------------------------------"); } Console.ReadLine(); }3. Press F5 to run and see the results.
4. Thank you.
Rectangular array is another type of array that allows
you to define a table like array that has a row and column definition.
Syntax:
type[,] = new type[row,column];
type – can be any data type
row – is the number of rows for your table
column – is the number of columns for your table
e.g.
int[,]
mytable = new int[10, 5];
-----------------------------------------------------------------------------------------------------
Manage and share your stuff. Sign up now for FREE!
meestuf.com
-----------------------------------------------------------------------------------------------------
Manage and share your stuff. Sign up now for FREE!
meestuf.com
2 comments:
I'm glad you liked it.
Thanks.
Post a Comment