" requires arguments of type "1" I am trying to create a program that will create a...">

Using the generic type "System.Collections.Generic.List <T>" requires arguments of type "1"

I am trying to create a program that will create a vector, generate 100 random numbers (0 - 99), and then ask user input if they want to sort numbers from high to low or from low to high.

This is the code I'm still trying to get the vector to work.

using System;
using System.Collections.Generic;
using System.Collections.Generic.List; //this is where the error comes.
using System.Linq;
using System.Text;

namespace System.Collections.Generic
{
    class List<T>
    {
        static void Main(string[] args)
        {
            List<int> vectorList = new List<int>();
            vectorList.Capacity(100);
            int i = 100;
            for (int x = 0; x <= 100; x++)
            {
                Random rand = new Random();
                i = rand.Next(0, 100);
                vectorList.Add(i);
                Console.WriteLine(i);
            }
        }
    }
}

Except that I have no idea how to fix this problem, any help would be greatly appreciated.

+5
source share
5 answers

This is a side question (BoltClock has this right), but change this:

List<int> vectorList = new List<int>();
vectorList.Capacity(100);

For this:

List<int> vectorList = new List<int>(100);

Also remove <T>from your class name.

+9

using; List - , , "" .

Main() ; # Main().

, Joel Coehoorn answer , , , using , , . .

+9

, , , .

-, # using , , , .

using System.Collections.Generic.List

, (List<T>) - .

List<T> ... System.Collections.Generic . .NET List<T>, .

, ( ) , . .NET- . List<T>.

, ... T - . ... ListProcessor ( - ). , , . ( ), , , .NET, .

+8

:

using System.Collections.Generic.List;

, .

+1

You need to import the namespace. Therefore, delete the offensive line.

In addition, you have stated that your program class is shared List<T>. You do not need this, your entry point should only be in a regular static class.

+1
source

All Articles