Tasharen Entertainment Forum

Support => TNet 3 Support => Topic started by: lynohd on August 20, 2016, 12:43:54 PM

Title: List<> problem
Post by: lynohd on August 20, 2016, 12:43:54 PM
Hi, for some reason when i wanna use a list it gives me an error message saying:
Error   CS0104   'List<>' is an ambiguous reference between 'TNet.List<T>' and 'System.Collections.Generic.List<T>'   

is there any ways to use a list with TNET imported without having to put TNet.List infront of everything?

thanks in advance
Title: Re: List<> problem
Post by: ArenMook on August 20, 2016, 02:13:34 PM
Remove "using Systems.Collections.Generic;" from the top of your file, and there won't be a conflict.
Title: Re: List<> problem
Post by: lynohd on August 20, 2016, 02:19:39 PM
Thanks, But now it wont show up in the inspector anymore..  :-\
Title: Re: List<> problem
Post by: ArenMook on August 20, 2016, 02:29:26 PM
You can still use System.Collections.Generic.List for your inspector if you like. You just need to prefix it.
  1. public System.Collections.Generic.List<string> yourList;
Personally, I avoid using generic lists. When I need to show something in inspector, I just use an array.
  1. public string[] yourList;
Shorter code, less memory usage, identical inspector functionality.
Title: Re: List<> problem
Post by: nosyrbllewe on August 20, 2016, 03:47:06 PM
I personally prefer to use the System.Collections.Generic.List<>, so here is my solution.

At the top with the rest of the using statements, add:
  1. using S = System.Collections.Generic;
Now when you want to use the System List, you just type:
  1. S.List<string> myList = new S.List<string>();
It is not perfect by any means, but it is easier than typing out the full namespace every time. I just wonder why Aren has named his class in TNet List<> when in NGUI he has another one called BetterList<>. Maybe they could be consolidated into one class into part of something like "Tasharen Standard Assets"?
Title: Re: List<> problem
Post by: ArenMook on August 20, 2016, 04:16:39 PM
TNet is newer and better designed than NGUI, so it takes advantage of namespaces (which were not supported by Unity at the time NGUI was first created). List<> is meant to be a replacement of the generic one, which is why I named it the same. It's still in a namespace to make it possible to use both.