d2jsp
Gaming and Trading Community
Gaming and Trading Community
d2jsp Forums > Programmer's Haven > C/C++/C# > Just Need A Little Help With This C# Bit > 2 Errors Cant Spot Them
Add Reply New Topic New Poll
Page 1 of 1
JesseD
#1 Jan 24 2018 02:57pm
Group: Member
Posts: 153
Joined: Aug 11 2014
Gold: 0.00
using System;
using System.Collections.Generic;

public class Hello
{
public static void Main()
{
// TODO: add your code here
string<int> primenumbers = new list<int>();
primenumbers.add(2);
primenumbers.add(3);
primenumbers.add(5);
primenumbers.add(7);
primenumbers.add(11);

// test code
Console.WriteLine(primeNumbers.Count);
Console.WriteLine(primeNumbers[0]);
Console.WriteLine(primeNumbers[1]);
Console.WriteLine(primeNumbers[2]);
Console.WriteLine(primeNumbers[3]);
Console.WriteLine(primeNumbers[4]);

}
}
JesseD
#2 Jan 24 2018 06:09pm
Group: Member
Posts: 153
Joined: Aug 11 2014
Gold: 0.00
YCX
#3 Jan 24 2018 09:48pm
Group: Member
Posts: 95
Joined: Jan 24 2009
Gold: 2,313.85
Check your formatting. Are you using Visual Studio? It should help you point out errors with red underlines.
Code
using System;
using System.Collections.Generic;

public class Hello
{
public static void Main()
{
// TODO: add your code here
List< int > primenumbers = new List<int>();
primenumbers.Add(2);
primenumbers.Add(3);
primenumbers.Add(5);
primenumbers.Add(7);
primenumbers.Add(11);

// test code
Console.WriteLine(primenumbers.Count);
Console.WriteLine(primenumbers[0]);
Console.WriteLine(primenumbers[1]);
Console.WriteLine(primenumbers[2]);
Console.WriteLine(primenumbers[3]);
Console.WriteLine(primenumbers[4]);

}
}
Rusemen
#4 Jan 27 2018 03:32pm
Group: Member
Posts: 2,632
Joined: Sep 24 2013
Gold: 0.00
primeNumbers.Count() ?
Yakir
#5 Feb 11 2018 04:38am
Group: Members++
Posts: 18,868
Joined: Dec 20 2005
Gold: 15,100.00
Trader: Mediator
Quote (JesseD @ Jan 24 2018 11:57pm)
using System;
using System.Collections.Generic;

public class Hello
{
public static void Main()
{
// TODO: add your code here
string<int> primenumbers = new list<int>();
primenumbers.add(2);
primenumbers.add(3);
primenumbers.add(5);
primenumbers.add(7);
primenumbers.add(11);

// test code
Console.WriteLine(primeNumbers.Count);
Console.WriteLine(primeNumbers[0]);
Console.WriteLine(primeNumbers[1]);
Console.WriteLine(primeNumbers[2]);
Console.WriteLine(primeNumbers[3]);
Console.WriteLine(primeNumbers[4]);

}
}


What is the output you want from that code?
ArcSten
#6 Feb 11 2018 12:06pm
Group: Member
Posts: 15,716
Joined: Jan 22 2010
Gold: 1,650.00
Trader: Trusted
Quote (JesseD @ 24 Jan 2018 21:57)
using System;
using System.Collections.Generic;

public class Hello
{
public static void Main()
{
// TODO: add your code here
string<int> primenumbers = new list<int>();
primenumbers.add(2);
primenumbers.add(3);
primenumbers.add(5);
primenumbers.add(7);
primenumbers.add(11);

// test code
Console.WriteLine(primeNumbers.Count);
Console.WriteLine(primeNumbers[0]);
Console.WriteLine(primeNumbers[1]);
Console.WriteLine(primeNumbers[2]);
Console.WriteLine(primeNumbers[3]);
Console.WriteLine(primeNumbers[4]);

}
}


the bold part should be a list also
Go Back To C/C++/C# Topic List
Page 1 of 1