C
C#3y 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
DownOP3y 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
ero3y ago
well none of that uses a list
Down
DownOP3y ago
so how do i create a list?
ero
ero3y ago
using new List<double>()
Down
DownOP3y ago
var lista = new List<double>(); like this?
ero
ero3y ago
mhm
Down
DownOP3y ago
and how do i add values to it
ero
ero3y ago
list.Add(liczba), please use google this is the most straight forward stuff
Down
DownOP3y ago
ah okay thanks
Henkypenky
Henkypenky3y 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
ero3y 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
Accord3y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server