Yes; I somehow managed to get all the way down to Exercise #12.
If you could paste the code that you have so far for the PrettyPrintAll() and PrintAll() methods I could compare it to my notes.
The hint advises to begin with:
public static void PrettyPrintAll(IEnumerable filename)
One note of caution is that the Visual Studio threw out Error CS0106 “the modifier is not valid for this item”. I honestly don’t know the reason; Therefore, I removed the from the method definition.
At first I was confused about how “IEnumerable filename” could be used as an argument. However, the documentation explains that the data extracted by a LINQ query is considered to be of a type “IEnumerable”. So, we do not need to be concerned if there are multiple data types within a list. Our Language List contains data of both type “int” and type “string”. After extraction, they are of type “IEnumerable”.
The hint advises that we need to use the Prettify() method inside of a “foreach” loop. Is it possible to make the method function without using a “foreach” loop? It may be possible but I could not figure out how to iterate over each element without it.
So, the method should have the general form of:
static void PrettyPrintAll(IEnumerable filename)
foreach (T item in filename)
Then, the method should be called using an argument that contains all four items (Year, Name, ChiefDeveloper, Predecessors) from each data line.
This worked OK for me and printed out all four items from each line of data in the Language List.
The hint recommends that the first line of the Method is:
public static void PrintAll(IEnumerable sequence)
(Again, the VS threw an error so I deleted the modifier.)
Initially, I could not figure out why we could not simply re-use the argument from Exercise #10 and then replace the Prettify() method inside the loop with a different WriteLine() statement.
After reviewing the documentation, it appears that we need to use a different argument because after data is extracted by the <.Select> function of the query it is no longer in the “Language” Class. Specifically, data that is initially extracted by the <.Where> function of the query is in the “Language” Class. However, after further processing by the <.Select> function, it is in the “Object” Class. In my case, the Selected data was of a “string” type because I concatenated two data types (int, string) into a single string.
In general form:
static void PrintAll(IEnumerable filename)
foreach (Object variable in filename)
And, to call the method:
Note that the var SelectedData contains the item that was extracted by the .Select function from the lines that were initially screened by the .Where function in the query.
Finally, verify that you have all four of these headers at the top of your Program.cs file: