Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Udfordring: Ordbøger | Datastrukturer og Filhåndtering
C# Ud Over Det Grundlæggende

bookUdfordring: Ordbøger

Udfyld felterne for at erklære et nyt dictionary kaldet book, samt for at tilføje og udskrive data. Brug implicit erklæring til at oprette dictionary'en.

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. Brug Add-metoden til at tilføje data til dictionary'en.
  2. Du kan tilgå værdier fra dictionary'en ved at bruge syntaksen dictionaryName[keyName].
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"]); } } }
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 5

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

Awesome!

Completion rate improved to 2.04

bookUdfordring: Ordbøger

Stryg for at vise menuen

Udfyld felterne for at erklære et nyt dictionary kaldet book, samt for at tilføje og udskrive data. Brug implicit erklæring til at oprette dictionary'en.

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. Brug Add-metoden til at tilføje data til dictionary'en.
  2. Du kan tilgå værdier fra dictionary'en ved at bruge syntaksen dictionaryName[keyName].
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"]); } } }
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 5
some-alt