item.stateChanges(["child_added"]).subscribe((data) => {
var items = data.payload.val();
})
该代码不起作用,因为" MyComparer"不包含"长度"的定义,那么如何访问长度?
答案 0 :(得分:2)
您正在实施错误的界面。您需要IComparer<string>
代替:
class MyComparer : IComparer<string>
{
public int Compare(string x, string y)
{
int diff = x.Length - y.Length;
}
}