First of all, your question.
If you do know how to draw 1 string, and you want to draw 2 strings combined with a separator between them ",", simply do this:
...
string firstString = ...
string secondString = ...
string toBeDrawn = firstString + "," + secondString;
DrawThisFellah ( toBeDrawn );
...
So, you have a string[]
? No problem:
...
string[] currentElement = ...
string firstString = currentElement[0];
string secondString = currentElement[1];
// etc
...
Secondly, you don't need to add the leading zeros just for the alphabetical OrderByDescending
to work. You could parse (and thus validate) the strings and store them in elements of type int[]
instead of string[]
.
THIRD, and this might interest you !
It is dangerous to use LINQ without knowing you're using it.
Are you aware that your IEnumerable<string[]>
are actually queries, right ?
One could say that your IEnumerable<string[]>
objects are actually "CODE AS DATA".
They contain not the result for your OrderByDescending
but rather the logic itself.
That means that if you have say, 3 string[]
elements in your lineData
:
{ "1", "122" }, { "3", "42" }, { "5", "162" }
and you call OrderScores
, then you will notice the results when enumerating scoresDesNormal
(for instance). The following code:
foreach (var element in scoresDesNormal)
Console.WriteLine("{0}, {1}", element[0], element[1]);
would print out to the console:
1, 122
5, 162
(because the 2nd element has no '1' characters on the second subelement)
but if you go on and modify the lineData
collection either by inserting new elements or removing elements (should it be a List<string[]>
) or simply by modifying the values of existing elements (should it be a primitive array), then you will observe new results when enumerating scoresDesNormal
without calling OrderScores
!
So for instance the following code's comments are true (given you have a List<string[]> lineData
):
List<string[]> lineData = new List<string[]>(new[] {
new[] { "1", "122" }, // contains 1
new[] { "3", "42" }, // does not contain 1
new[] { "5", "162" } // contains 1
});
OrderScores();
foreach (var element in scoresDesNormal)
Console.WriteLine(element[1]);
// the previous foreach prints out
// 162
// 122
lineData[1][1] = "421"; // make the "42" in the list become "421"
foreach (var element in scoresDesNormal)
Console.WriteLine(element[1]);
// the previous foreach prints out - even though we haven't called OrderScores again
// 162
// 421
// 122