Could iPhone use template pattern?

Because of System.Collection.Generics not support for iPhone, so I make the custom STL to use.

I know ArrayList and Hashtable can use, but I hope it can auto cast type when I get the value or key…

The custom STL is working on Unity 2.5 version, but it seems not working on iPhone version…
Seems there’s a parsing error on template syntax <>

If any one has a idea of this, please let me know.
Thanks a lot!!! :sweat_smile:

Generics are not supported in Unity at the moment because I believe it is using .NET 1.1.

I dont know if there’s a plan for Unity to upgrade to using .Net 2 or 3, but doing that will probably cause file sizes to increase, so I doubt if it will be worth it.

Bububear is right.
Unity iPhone is .NET 1.1 and likely will remain on that as it already now needs to cut / restrict functionality to even compile any longer for the iPhone due to the size of the corelib

Ummm, the STL is a C++ library. Templates do not exist in C# or JavaScript.

And as others have said, generics do not work in Unity iPhone as they are a .NET 2.0 feature and Unity iPhone uses .NET 1.1.

Thanks for reply!

I know that: Generics are not supported in Unity at the moment because I believe it is using .NET 1.1.

But it means not support “template design pattern” too???

I just make public class MyList : ArrayList just like List, but iPhone Unity has parsing error at <>…

Templates are not a design pattern, they are a language feature unique to C++. C# does not have templates.

C# does have generics, which are what you are trying to do. When you write MyClass, you are trying to use/define a generic, and as you know, Unity iPhone does not support generics, hence the parsing error.

Got it!!!
Thank you^^