C# Programming Languages Project

[Learn C# | Codecademy]
(https://www.codecademy.com/courses/learn-c-sharp/projects/csharp-programming-languages)

Hi team

Please can someone post a solution to this project? There is no solution provided with the project and I’m unable to check where I’m going wrong. Getting loads of errors from Step 1 alone (which is unusual).

Here’s what I’ve got for Step 1:

foreach (Language language in languages)

    {

      Console.WriteLine(language.Prettify());

    }

Thank you
Tanya

You need to make sure you keep the code that is already in the main function of Program.cs:

List<Language> languages = File.ReadAllLines("./languages.tsv")
        .Skip(1)
        .Select(line => Language.FromTsv(line))
        .ToList();

Thank you for getting back to me so quickly - I have kept it in there (I just didn’t paste it here as I was only pasting what I had added so far). Apologies for not making that clear.

It works when I put it in. You’re doing in Program.cs, right? Does your output look like this

It doesn’t, just a bunch of errors but it also keeps crashing… I think I’ll reboot everything and try again. Thanks for your help!
If you/anyone has finished the project, it would be good to compare against solution code at the end.

1 Like

Instead of “foreach (Language language in languages)”

try

“foreach (var language in languages)”

The reason is that each Language contains an int variable and 3 strings, so each component in “language” is not itself a Language.

Hope this works!