Extensions with Type Parameters
i have missing something, please help.
1 using system.collections.objectmodel; 2 using system.linq; 3 using system.collections; 4 using system.collections.generic; 5 using system; 6 7 namespace dashboard.helpers 8 { 9 public static class observablecollectionextentions 10 { 11 12 public static observablecollection<t> toobservablecollection(this ienumerable<t> collection) 13 { 14 //construct 15 observablecollection<t> returnvalue = new observablecollection<t>(); 16 17 //populate 18 foreach (var item in collection) 19 { 20 //returnvalue.add(item); 21 } 22 23 //return 24 return returnvalue; 25 } 26 27 } 28 }
error: the type or namespace name 't' not found (are missing using directive or assembly reference?)
hi,
a generic method method declared type parameters, instead of:
public static observablecollection<t> toobservablecollection(this ienumerable<t> collection)
you need to add <t> after method name, this:
public static observablecollection<t> toobservablecollection<t>(this ienumerable<t> collection)
Silverlight > Programming Silverlight with .NET – General
Comments
Post a Comment