neonbytes
neonbytes

Reputation: 357

Using Generics with Script#

I'm trying to refactor some of our Script# code to reduce duplicate code. I'm trying to use generics to accomplish this but Script# refuses to build when I add this code (the only message it gives me is 'Build failed'):

public abstract class PageManagerBase<TItem>
{
    public List<TItem> _items;
}

Does anyone know if there's a workaround for this?

Upvotes: 2

Views: 396

Answers (2)

Steve Hobbs
Steve Hobbs

Reputation: 3326

Script# supports generics for internal types only, so things like Dictionary<TKey, TValue>, or List<T>, but doesn't support custom types that you would create yourself.

So, you can use the ones that are already provided for you, but you can't create your own.

Upvotes: 4

Leon
Leon

Reputation: 552

I don't think script# supports generics yet. check out the roadmap over here http://projects.nikhilk.net/ScriptSharp

Upvotes: 0

Related Questions