为什么不能限定在下面的例子中LLSGroupsWithItems(它不会编译):无法创建的自定义类的ObservableCollection <的ObservableCollection <T>>
public class LLSGroupsWithItems<Group<T>> : ObservableCollection<Group<T>>
{
}
public class Group<T> : ObservableCollection<T>
{
public Group(string name, IEnumerable<T> items)
{
this.Key = name;
foreach (T item in items)
{
this.Add(item);
}
}
public override bool Equals(object obj)
{
Group<T> that = obj as Group<T>;
return (that != null) && (this.Key.Equals(that.Key));
}
public string Key
{
get;
set;
}
}
编译器错误是:
Type parameter declaration must be an identifier not a type.
长的故事:
我已经看到了有关如何动态地添加项目到一个表单ObservableCollection<ObservableCollection<T>>
,b的结构上WindowsPhoneGeek为例ut我想在我的LongListSelector所绑定的集合中封装一个自动分组功能,这样我就不必总是查看要添加特定项目的组。为此,我想,我需要创建一个我想要定义的类,但是C#限制或者其他东西不会让我知道。请解释原因。谢谢。
Visual Studio 2010的启动速度很慢,所以我懒得粘贴它,看看编译器给出了什么错误。 – BoltClock
如何告诉我们错误信息是什么? –