Learn C# with CSharpFritz - Collections and Generics

preview_player
Показать описание
Fritz is back and teaching C# for beginners. This time we're learning about working with collections of data like arrays and lists. We'll also take a peek into how LINQ works





#csharp, #beginner, #dotnet
Рекомендации по теме
Комментарии
Автор

25 minutes of waffle before the content is a bit rich

markharby
Автор

foreach(item in Collection) throws an error message...

I'm trying to populate the mainpage, footer and navigation with the same set of navigation links (and depening on the page language, so it's about LINQ too)
The FOR cycle works just fine, it's FOREACH that throws out an error

public class Catalog {

public readonly record struct Link (string Relative, string Language, string ShortName, string LongName, string Title);

public static Link[] Services = new Link[]
{
new Link("/services/translator.html", "en", "Russian \u21D4 English Translation", "Russian-English Bi-directional Translation", "Translation and Localization Services"),
new Link("/tutor/english.html", "en", "English Tutor", "English Language Tutor", "English language instructor")
};

public static Link[] Articles = new Link[]
{ another set of records}

}

The FOR cycle works just fine:
for (i=0, i<Catalog.Serivices.Length; i++) {styling}

I'm trying to use @foreach ( Link in Catalog ) {styling}
and receive an error

Is that about using interfaces instead?

nakigoe_org