少有人走的路

勇哥的工业自动化技术网站

[netMarketing类库] listHelper类: List数据类型辅助处理类


命名空间:sharClass.listHelper

功能:List数据类型辅助处理类


功能详细说明:

这个类封装了方便处理List列表的一些方法。

注意这些函数参数中有this关键字,说明它们是扩展方法。

扩展方法的调用方式跟List对象自身的方法调用是一样的。

例如:

var list1=new List<string>();
list1.Add("world");
list1.Add("hello");
MessageBox.Show(list1.getNewLineString());


常用函数列表

/// 一维List转二维数组, 因为二维数据定义后赋值比较麻烦,可以用本方法把一个list数据转为一个二维数组
public static T[,] listToArray2<T>(this List<T> data, int columns)
/// 返回指定列数据,出错返回null
public static List<T> getColumnData<T>(this List<T> data,int columns,int selColNo)
/// 返回指定行数据,出错返回null
public static List<T> getRowData<T>(this List<T> data, int columns, int selRowNo)
/// 由中值分类数据, 小于中值的分类型Item1,大于中值的分类到Item2
public static Tuple<List<T>, List<T>> classifyDataByMidValue<T>(this List<T> list, double midData)
/// 求List的平均值
public static double avg<T>(this List<T> data)
/// 取数值类型List列表的最大元素值
public static T max<T>(this List<T> data)
/// T数组转List T
public static List<T> toList<T>(this T[] data)
/// 求T数组的最大元素
public static T max<T>(this T[] data)
/// 取数值类型List列表的最小元素
public static T min<T>(this List<T> data)
/// 取数值类型T数组的最小元素
public static T min<T>(this T[] data)
/// 生成List,值的逗号分隔字符串
public static string getCommaString<T>(this List<T> data)
//   生成List,值的换行分隔的字符串
public static string getNewLineString<T>(this List<T> data)
/// 把二维List转为一维数据结构
 public static IList<Queue<double>> ListToQueue(this List<List<double>> data)
/// 取二维List最大值
public static double getMax(this List<List<double>> data)
///  取二维List最小值
public static double getMin(this List<List<double>> data)
/// 取按列排序的数据列表. 一般数据按行读取,如果要按列统计则可调用本函数,取得列排列的数据列表
public static List<List<double>> GetVerticalData(this List<List<double>> data)
/// 把二维的Queue转为List
public static List<List<double>> QueueToList(this IList<Queue<double>> data)

--------------------- 

作者:hackpig
来源:www.skcircle.com
版权声明:本文为博主原创文章,转载请附上博文链接!

返回类库功能说明目录


发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

«    2025年12月    »
1234567
891011121314
15161718192021
22232425262728
293031
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
搜索
最新留言
文章归档
网站收藏
友情链接

Powered By Z-BlogPHP 1.7.3

Copyright www.skcircle.com Rights Reserved.

鄂ICP备18008319号


站长QQ:496103864 微信:abc496103864