Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Herausforderung: Dictionaries | Datenstrukturen & Dateiverarbeitung
C# Jenseits der Grundlagen

bookHerausforderung: Dictionaries

Ergänzen Sie die Lücken, um ein neues Dictionary namens book zu deklarieren, sowie um Daten hinzuzufügen und auszugeben. Verwenden Sie für die Erstellung des Dictionaries eine implizite Deklaration.

index.cs

index.cs

copy
123456789101112131415161718192021222324
using System; using System.Collections.Generic; namespace ConsoleApp { class Program { static void Main(string[] args) { // Declaring a new empty dictionary ___ ___ = new Dictionary<string, string>(); // Adding data to the dictionary ___("name", "The Hobbit"); ___("author", "J. R. R. Tolkien"); ___("publication date", "21 September 1937"); // Outputting data Console.WriteLine("Book Name: " + ___); Console.WriteLine("Author: " + ___); Console.WriteLine("Publication Date: " + ___); } } }
  1. Verwenden Sie die Methode Add, um Daten zum Dictionary hinzuzufügen.
  2. Sie können auf Werte im Dictionary mit der Syntax dictionaryName[keyName] zugreifen.
index.cs

index.cs

copy
123456789101112131415161718192021222324
using System; using System.Collections.Generic; namespace ConsoleApp { class Program { static void Main(string[] args) { // Declaring a new empty dictionary var book = new Dictionary<string, string>(); // Adding data to the dictionary book.Add("name", "The Hobbit"); book.Add("author", "J. R. R. Tolkien"); book.Add("publication date", "21 September 1937"); // Outputting data Console.WriteLine("Book Name: " + book["name"]); Console.WriteLine("Author: " + book["author"]); Console.WriteLine("Publication Date: " + book["publication date"]); } } }
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 5

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Awesome!

Completion rate improved to 2.04

bookHerausforderung: Dictionaries

Swipe um das Menü anzuzeigen

Ergänzen Sie die Lücken, um ein neues Dictionary namens book zu deklarieren, sowie um Daten hinzuzufügen und auszugeben. Verwenden Sie für die Erstellung des Dictionaries eine implizite Deklaration.

index.cs

index.cs

copy
123456789101112131415161718192021222324
using System; using System.Collections.Generic; namespace ConsoleApp { class Program { static void Main(string[] args) { // Declaring a new empty dictionary ___ ___ = new Dictionary<string, string>(); // Adding data to the dictionary ___("name", "The Hobbit"); ___("author", "J. R. R. Tolkien"); ___("publication date", "21 September 1937"); // Outputting data Console.WriteLine("Book Name: " + ___); Console.WriteLine("Author: " + ___); Console.WriteLine("Publication Date: " + ___); } } }
  1. Verwenden Sie die Methode Add, um Daten zum Dictionary hinzuzufügen.
  2. Sie können auf Werte im Dictionary mit der Syntax dictionaryName[keyName] zugreifen.
index.cs

index.cs

copy
123456789101112131415161718192021222324
using System; using System.Collections.Generic; namespace ConsoleApp { class Program { static void Main(string[] args) { // Declaring a new empty dictionary var book = new Dictionary<string, string>(); // Adding data to the dictionary book.Add("name", "The Hobbit"); book.Add("author", "J. R. R. Tolkien"); book.Add("publication date", "21 September 1937"); // Outputting data Console.WriteLine("Book Name: " + book["name"]); Console.WriteLine("Author: " + book["author"]); Console.WriteLine("Publication Date: " + book["publication date"]); } } }
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 5
some-alt