110,896
社区成员
发帖
与我相关
我的任务
分享
RSI_Collection<Rsi_List> l_list = g_Value_RSI["AA"];
var l_var = l_list.Where(p => p.time <= g_readtime).ToList();
RSI_Collection<Rsi_List> l_templist1 = l_list.Where(p => p.time <= g_readtime);
//TEST_Collection<TEST_LIST>
var l_temp = l_list.Where(p => p.id > 5);
Console.WriteLine(l_temp.GetType());
foreach (var x in l_temp) Console.WriteLine("id:{0} name:{1}", x.id, x.name);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Trade_Test
{
public class TEST_LIST
{
public int id { get; set; }
public string name { get; set; }
}
public class TEST_Collection<T> : System.Collections.ObjectModel.ObservableCollection<T>
{
private int a_MaxCount = 0;
/// <summary>
/// 数组的最大值,超过这个值,就会删除第一条记录
/// </summary>
public int s_MaxCount
{
get { return a_MaxCount; }
set { a_MaxCount = value; }
}
public TEST_Collection()
{
base.CollectionChanged += TEST_Collection_CollectionChanged;
}
private void TEST_Collection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (e.NewItems != null)
{
if (Count > a_MaxCount) { RemoveAt(0); }
}
}
}
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
TEST_Collection<TEST_LIST> l_list = new TEST_Collection<TEST_LIST>();
l_list.s_MaxCount = 5;
l_list.Add(new TEST_LIST { id = 1, name = "11" });
l_list.Add(new TEST_LIST { id = 2, name = "22" });
l_list.Add(new TEST_LIST { id = 3, name = "33" });
l_list.Add(new TEST_LIST { id = 4, name = "44" });
l_list.Add(new TEST_LIST { id = 5, name = "55" });
l_list.Add(new TEST_LIST { id = 6, name = "66" });
l_list.Add(new TEST_LIST { id = 7, name = "77" });
TEST_Collection<TEST_LIST> l_temp = l_list.Where(p => p.id > 5);
}
}
}
a = 1;
为什么出错(例如a可能声明是一个字典类型的),那么就回到刚学的时候的状态。
而你这个帖子,根本不知道你所谓的 PART_Collection<> 是什么东东,难道就靠胡乱瞎猜就能编程?