Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Desafio: Dicionários | Estruturas de Dados e Manipulação de Arquivos
C# Além do Básico

bookDesafio: Dicionários

Preencha as lacunas para declarar um novo dicionário chamado book, além de adicionar e exibir dados. Utilize declaração implícita para criar o dicionário.

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. Utilize o método Add para adicionar dados ao dicionário.
  2. É possível acessar valores do dicionário usando a sintaxe 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"]); } } }
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 5

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Suggested prompts:

Can you show me an example of how to declare and add data to the dictionary?

What does "implicit declaration" mean in this context?

How do I output the data from the dictionary?

Awesome!

Completion rate improved to 2.04

bookDesafio: Dicionários

Deslize para mostrar o menu

Preencha as lacunas para declarar um novo dicionário chamado book, além de adicionar e exibir dados. Utilize declaração implícita para criar o dicionário.

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. Utilize o método Add para adicionar dados ao dicionário.
  2. É possível acessar valores do dicionário usando a sintaxe 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"]); } } }
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 5
some-alt