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

bookDesafio: Declaração de Lista

Preencha as lacunas para declarar uma lista chamada numbers que armazena números inteiros de 1 a 10. Utilize declaração explícita para declarar a lista.

index.cs

index.cs

copy
12345678910111213
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { ___ ___ = ___ ___ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; foreach (int num in numbers) Console.Write(num + " "); } }

Você declara listas vazias utilizando a sintaxe List<type> name = new List<type>();. Inicializar uma lista com alguns dados possui uma sintaxe muito semelhante.

index.cs

index.cs

copy
12345678910111213
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { List<int> numbers = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; foreach (int num in numbers) Console.Write(num + " "); } }
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 2

Pergunte à IA

expand

Pergunte à IA

ChatGPT

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

Awesome!

Completion rate improved to 2.04

bookDesafio: Declaração de Lista

Deslize para mostrar o menu

Preencha as lacunas para declarar uma lista chamada numbers que armazena números inteiros de 1 a 10. Utilize declaração explícita para declarar a lista.

index.cs

index.cs

copy
12345678910111213
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { ___ ___ = ___ ___ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; foreach (int num in numbers) Console.Write(num + " "); } }

Você declara listas vazias utilizando a sintaxe List<type> name = new List<type>();. Inicializar uma lista com alguns dados possui uma sintaxe muito semelhante.

index.cs

index.cs

copy
12345678910111213
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { List<int> numbers = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; foreach (int num in numbers) Console.Write(num + " "); } }
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

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