Utfordring: Deklarasjon av Liste
Fyll ut de tomme feltene for å erklære en liste kalt numbers som lagrer heltall fra 1 til 10. Bruk eksplisitt deklarasjon for å erklære listen.
index.cs
12345678910111213using 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 + " "); } }
Du erklærer tomme lister ved å bruke syntaksen List<type> name = new List<type>();. Initialisering av en liste med data har en svært lik syntaks.
index.cs
12345678910111213using 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 + " "); } }
Takk for tilbakemeldingene dine!
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Can you give me a hint for filling in the blanks?
Can you show me the solution for declaring the list?
Can you explain what "explicit declaration" means in this context?
Awesome!
Completion rate improved to 2.04
Utfordring: Deklarasjon av Liste
Sveip for å vise menyen
Fyll ut de tomme feltene for å erklære en liste kalt numbers som lagrer heltall fra 1 til 10. Bruk eksplisitt deklarasjon for å erklære listen.
index.cs
12345678910111213using 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 + " "); } }
Du erklærer tomme lister ved å bruke syntaksen List<type> name = new List<type>();. Initialisering av en liste med data har en svært lik syntaks.
index.cs
12345678910111213using 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 + " "); } }
Takk for tilbakemeldingene dine!