4 Replies - 686 Views - Last Post: 10 April 2010 - 08:42 AM Rate Topic: -----

#1 pratyushakandala  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 23-March 10

Help with arrays in C#

Posted 31 March 2010 - 07:19 AM

What is the logic to implement

1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5


using arrays in c#???

This post has been edited by PsychoCoder: 31 March 2010 - 08:57 AM
Reason for edit:: Title edited to be more descriptive

Is This A Good Question/Topic? 0
  • +

Replies To: Help with arrays in C#

#2 FlashM  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 380
  • View blog
  • Posts: 1,195
  • Joined: 03-December 09

Re: Help with arrays in C#

Posted 31 March 2010 - 07:29 AM

what is this supposed to represent? Matrix?
Was This Post Helpful? 0
  • +
  • -

#3 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 764
  • View blog
  • Posts: 5,095
  • Joined: 08-December 08

Re: Help with arrays in C#

Posted 31 March 2010 - 07:41 AM

If that is a bidimensional array, then the declaration will be like this:

int[,] myArray = new int[4,5];
myArray[0, 0] = 1;
myArray[0, 1] = 1;
// Continue code


Was This Post Helpful? 0
  • +
  • -

#4 pratyushakandala  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 23-March 10

Re: Help with arrays in C#

Posted 10 April 2010 - 08:37 AM

using System;
using System.Collections.Generic;
using System.Text;

namespace Practice
{
    class Class2
    { 
        public static void Main(string[] args)
        {
            int[,] arr = new int [5,5];
            int i,j,k;
            k=1;
            for(i=0;i<5;i++)
            {
                 for (j = 0; j < 5; j++)
                 {
                     arr[i,j] = k;
                 }
                ++k;
            }
            Console.WriteLine("Reduired Matrix Format");
            for (i = 0; i < 5; i++)
            {
                for (j = 0; j < 5; j++)
                {
                    Console.Write(" " + arr[i, j]);
                }
                Console.WriteLine();
            }
            Console.ReadLine();
        }

    }
}



Admin Edit: Please use code tags when posting your code. Code tags are used like so => :code:

Thanks,
PsychoCoder :)
Was This Post Helpful? 0
  • +
  • -

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1619
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Help with arrays in C#

Posted 10 April 2010 - 08:42 AM

Come on man .... lean how to ask a proper question ...

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:


  • Post the code you're having problems with (DONE)
  • Post the exact error you're receiving, if you are receiving one
  • If no error explain what the code is doing versus what you want it to do
  • Post your question in the body of your post, not the description field

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1