Generic List type function

Hello everyone,

I’ve searched all results talking about Generic Lists out there and I wasn’t able to find the right way to type a function as Generic List, I would like to to something like this:

function GetList() : List<Texture2D>
{
        var foo : List.<Texture2D> = new List.<Texture2D>();
        foo.Add( myTex );

	return foo;
}

Thanks in advance!

What error have you got?
Your code looks well, and should working. Maybe you forget a namespace?

The same code on C# with namespace

public System.Collections.Generic.List<Texture2D> GetList()
{
   System.Collections.Generic.List<Texture2D> foo = new System.Collections.Generic.List<Texture2D>();
   foo.Add( myTex );
   return foo;
}

and without namespace, but with using declaration:

using System.Collections.Generic;

public List<Texture2D> GetList()
{
   List<Texture2D> foo = new List<Texture2D>();
   foo.Add( myTex );
   return foo;
}

Try adding the following line at the start of your script (immediately below any #pragma statements):

import System.Collections.Generic;

List should be List., like in the rest of your code.

–Eric

Damn I can’t believe I’m such an ass. Alright that was List. isntead of List. Just a f*ckin typo. Thanks everyone!