Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 6:04
N8tiv20-May-13 6:04 
GeneralRe: Understanding Jagged Arrays Pin
Richard MacCutchan20-May-13 7:19
mveRichard MacCutchan20-May-13 7:19 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 7:30
N8tiv20-May-13 7:30 
GeneralRe: Understanding Jagged Arrays Pin
Matt T Heffron20-May-13 8:49
professionalMatt T Heffron20-May-13 8:49 
GeneralRe: Understanding Jagged Arrays Pin
Richard MacCutchan20-May-13 22:26
mveRichard MacCutchan20-May-13 22:26 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv23-May-13 15:24
N8tiv23-May-13 15:24 
GeneralRe: Understanding Jagged Arrays Pin
Richard MacCutchan23-May-13 20:42
mveRichard MacCutchan23-May-13 20:42 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv23-May-13 21:15
N8tiv23-May-13 21:15 
I don't know if you had seen what my drill/exercise was supposed to be… I'm willing to bet a case of beer you be able to figure it out by looking at what I wrote…
I wrote it out the long and hard way… Only because at first, I couldn't quite figure out how to incorporate the for loop.
C#
using System;
using System.Text;
 
namespace Two_Dimensional_Array
{
    class Program
    {
        static void Main(string[] args)
        {
            string[,] grades = { { "Pass", "Good", "VeryGood", "Distinct" }, { "55%", "65%", "75%", "85%" } };
            string[] gradeScore = {"Grade=", "Score="};
            Console.WriteLine(gradeScore[0] + grades[0, 0] + "         " + gradeScore[1] + grades[1, 0]);
            Console.WriteLine(gradeScore[0] + grades[0, 1] + "         " + gradeScore[1] + grades[1, 1]);
            Console.WriteLine(gradeScore[0] + grades[0, 2] + "     " + gradeScore[1] + grades[1, 2]);
            Console.WriteLine(gradeScore[0] + grades[0, 3] + "     " + gradeScore[1] + grades[1, 3]);
            Console.Read();
        }
    }
}


After fiddling around with it for a couple of days, I was able to get the for loop in… But, as you'll notice from the code above… The first two lines that print to the screen are spaced out just a little bit further so the Score column is all lined up just like the way they wanted in the book.
Is there some sort of extra C# technique/trick to have the columns line up?
C#
using System;

namespace Two_Dimensional_Array
{
    class Program
    {
        static void Main(string[] args)
        {
            string[,] grades = { { "Pass", "Good", "VeryGood", "Distinct" }, { "55%", "65%", "75%", "85%" } };
            string[] gradeScore = {"Grade=", "Score="};
            for (int a = 0; a < 4; a++)
                {
                    Console.WriteLine(gradeScore[0] + grades[0, a] + "      " + gradeScore[1] + grades[1, a]);
                }
                Console.Read();
        }
    }
}


GeneralRe: Understanding Jagged Arrays Pin
Richard MacCutchan23-May-13 22:22
mveRichard MacCutchan23-May-13 22:22 
GeneralRe: Understanding Jagged Arrays Pin
Jasmine250120-May-13 10:44
Jasmine250120-May-13 10:44 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 10:47
N8tiv20-May-13 10:47 
GeneralRe: Understanding Jagged Arrays Pin
Jasmine250120-May-13 10:52
Jasmine250120-May-13 10:52 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 10:57
N8tiv20-May-13 10:57 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 11:06
N8tiv20-May-13 11:06 
GeneralRe: Understanding Jagged Arrays Pin
Jasmine250120-May-13 11:18
Jasmine250120-May-13 11:18 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 12:00
N8tiv20-May-13 12:00 
GeneralRe: Understanding Jagged Arrays Pin
Jasmine250120-May-13 12:47
Jasmine250120-May-13 12:47 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 13:04
N8tiv20-May-13 13:04 
GeneralRe: Understanding Jagged Arrays Pin
Jasmine250120-May-13 13:31
Jasmine250120-May-13 13:31 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv20-May-13 13:41
N8tiv20-May-13 13:41 
GeneralRe: Understanding Jagged Arrays Pin
N8tiv23-May-13 21:17
N8tiv23-May-13 21:17 
Questioncounting in c# Pin
MKS Khalid20-May-13 0:50
MKS Khalid20-May-13 0:50 
AnswerRe: counting in c# Pin
Eddy Vluggen20-May-13 1:17
professionalEddy Vluggen20-May-13 1:17 
AnswerRe: counting in c# Pin
Pete O'Hanlon20-May-13 1:26
mvePete O'Hanlon20-May-13 1:26 
AnswerRe: counting in c# Pin
Keith Barrow20-May-13 2:12
professionalKeith Barrow20-May-13 2:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.