zoukankan      html  css  js  c++  java
  • 扩展类

        public static class Extensions
        {
            //2016.1.18 start
            public static int toInt(this string str) {
                return Convert.ToInt32(str);
            }
            public static  bool IsNullOrEmpty(this string s)
            {
                return string.IsNullOrEmpty(s);
            }
        }
    }
    

      

    2016.2.26

    增加泛型去重复

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace ssm.Helper
    {
        public static class Extensions
        {
            //2016.1.18 start
            public static int toInt(this string str) {
                return Convert.ToInt32(str);
            }
            public static  bool IsNullOrEmpty(this string s)
            {
                return string.IsNullOrEmpty(s);
            }
    
            public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
            {
                HashSet<TKey> seenKeys = new HashSet<TKey>();
                foreach (TSource element in source)
                {
                    if (seenKeys.Add(keySelector(element)))
                    {
                        yield return element;
                    }
                }
            }
        }
    }
    

      

  • 相关阅读:
    清除缓存
    框架更新 (简)
    Xutils简
    动画
    夜间模式
    TabLoaout简单框架
    atomic原子类的理解
    单例模式中指令重排序及需要使用volatile的理解
    对volatile的理解
    jvm内存模型及垃圾回收GC
  • 原文地址:https://www.cnblogs.com/0to9/p/5139096.html
Copyright © 2011-2022 走看看