Type.GetType(), soru çözülmesi için de HashSet <T> ve Montaj Yeterlilik
ben anlamıyorum Type.GetType (string typeName) davranışı karşılaştım.
bir List<int>
tipini almak, bu
olarak türünü belirtmek için yeterli olduğunda System.Collections.Generic.List`1 [[System.ınt32]]
Ancak HashSet<int>
için ben bu
System.Collections.Generic.HashSet`1 [[System.Int32]], System.Core, Sürüm = 4.0.0.0, Culture = nötrleştirme gibi tam tür adı belirtmelisiniz arkadaşları, PublicKeyToken b77a5c561934e089
ben montaj, sürüm, kültür, veya ortak anahtar belirteci herhangibırakırsanız
yazın çözülmezse =.Kod
// Returns expected type:
Type tListWorks =
Type.GetType("System.Collections.Generic.List`1[[System.Int32]]");
// Returns null:
Type tHashSetNull =
Type.GetType("System.Collections.Generic.HashSet`1[[System.Int32]]");
// Returns expected type:
Type tHashSetWorks =
Type.GetType("System.Collections.Generic.HashSet`1[[System.Int32]], System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
// Returns null (omitted Culture):
Type tHashSetNoCultureFails =
Type.GetType("System.Collections.Generic.HashSet`1[[System.Int32]], System.Core, Version=4.0.0.0, PublicKeyToken=b77a5c561934e089");
Sorular
- Neden tam
HashSet<T>
nitelemek gerekir ancakList<T>
çoğaltmak? - Sürüm kalifikasyonunun belirtilmesi gerektiği göz önünde bulundurulduğunda, .NET Çalıştırıcısı 3.5 ise (
HashSet<T>
olan ilk) ya da .NET 4.5 gibi bir sonraki sürümde? Ne zaman çalışma zamanı tamamen Silverlight veya Mono gibi bir şeyse?
(ı denemedim ama) Bu da çalışması gerekir: 'System.Collections.Generic.HashSet'1 [[System.Int32]], System.Core' –
@Andrey: Bu benim beklentisi çok oldu ama bu işe yaramıyor. –
bu alakalı olabilir: http://stackoverflow.com/a/2367674/39068 –