C
C#2y ago
Down

how to add to list [Answered]

um so i want to add numbers to list until user inputs 0 and then print sum average etc but idk how to use lists
12 Replies
Down
Down2y ago
using System;

namespace Zadania
{
class Program
{
static void Main(string[] args)
{
double[] lista;
double liczba;

do
{
Console.WriteLine("Podaj liczbe: ");
liczba = double.Parse(Console.ReadLine());
// how to add to list
}
while (liczba != 0);
}
}
}
using System;

namespace Zadania
{
class Program
{
static void Main(string[] args)
{
double[] lista;
double liczba;

do
{
Console.WriteLine("Podaj liczbe: ");
liczba = double.Parse(Console.ReadLine());
// how to add to list
}
while (liczba != 0);
}
}
}
ero
ero2y ago
well none of that uses a list
Down
Down2y ago
so how do i create a list?
ero
ero2y ago
using new List<double>()
Down
Down2y ago
var lista = new List<double>(); like this?
ero
ero2y ago
mhm
Down
Down2y ago
and how do i add values to it
ero
ero2y ago
list.Add(liczba), please use google this is the most straight forward stuff
Down
Down2y ago
ah okay thanks
Henkypenky
Henkypenky2y ago
that's why we have this help channels, otherwise we just say google it to everyone, if you don't feel like answering don't answer
ero
ero2y ago
bogus, people need to learn to help themselves it's not like these are insane intricacies discussed in #roslyn and #allow-unsafe-blocks which you literally cannot answer without people from those channels
Accord
Accord2y ago
✅ This post has been marked as answered!