Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I made this jagged array but now i want to convert this array in to dynamic array.
It mean that it ask to user that enter the no of rows and then ask for the values.
then print it .
But i am unable to do this job . any body to assist me ???
thanks to all .


C#
namespace JaggedArray
{

    class Program
    {

        static void Main(string[] args)
        {
            int[][] A =new  int[2][]{new int[]{12,34,45,56},new int[]{90,78,45}};
           // A[0] = new int[] { 23, 45, 45, 34, 34, 34 };
           // A[1] = new int[] { 23, 12 };

            for (int r = 0; r < A.Length; r++)
            {
                for (int c = 0; c < A[r].Length; c++)
                {
                    Console.Write(A[r][c]+"      ");
                }
                Console.WriteLine("");
            }
            Console.ReadKey();
        }
    }
}
Posted
Updated 16-Sep-13 9:41am
v4
Comments
thatraja 10-Sep-13 3:45am    
No one is going to give you code, please use google first, when you stuck on something then come here with complete details
Mr.Driod 15-Sep-13 13:56pm    
sir question is updates please have a look ...!!!
[no name] 10-Sep-13 3:49am    
Try by yourself first.if there is any problem then let us know..
Mr.Driod 15-Sep-13 13:56pm    
sir question is updates please have a look ...!!!
Marvin Ma 10-Sep-13 3:51am    
Have a look at this and try on your own first:

http://msdn.microsoft.com/en-us/library/2s05feca.aspx

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!
 
Share this answer
 
Comments
Mr.Driod 15-Sep-13 13:55pm    
sir question is updates please have a look ...!!!
BillWoodruff 16-Sep-13 23:42pm    
This seems to me to be appropriate as a comment on the OP, but, not as a solution.

"keeping comments comments, and solutions solutions, is as important as virgins' virginity" bw
OriginalGriff 17-Sep-13 4:05am    
Did you notice he changed the question between my "solution" and your comment? :laugh:
C#
namespace Driod
{
    class Program
    {
        static void Main(string[] args)
        {

            Console.WriteLine("Enter Rows...");
            int rows = int.Parse(Console.ReadLine());
            Console.WriteLine("Enter Rows...");
            int columns = int.Parse(Console.ReadLine());
            int[,] arr = new int[rows, columns];

            Console.WriteLine("Enter the value in Integers");
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int c = 0; c < arr.GetLength(1); c++)
                {
                    Console.WriteLine("Enter value for number " + i + " and " + c);
                    arr[i, c] = int.Parse(Console.ReadLine());
                }
            }
            Console.WriteLine("the output value  is");
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int c = 0; c < arr.GetLength(1); c++)
                {
                    Console.Write(arr[i, c]+"\t\t");
                }
                Console.Write("\n");
            }
            Console.ReadLine();
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900