Fan.Sys.Type.common C# (CSharp) Method

common() public static method

Given a list of objects, compute the most specific type which they all share,or at worst return sys::Obj. This method does not take into account interfaces, only extends class inheritance.
public static common ( object objs, int n ) : Type
objs object
n int
return Type
        public static Type common(object[] objs, int n)
        {
            if (objs.Length == 0) return Sys.ObjType.toNullable();
              bool nullable = false;
              Type best = null;
              for (int i=0; i<n; ++i)
              {
            object obj = objs[i];
            if (obj == null) { nullable = true; continue; }
            Type t = @typeof(obj);
            if (best == null) { best = t; continue; }
            while (!t.@is(best))
            {
              best = best.@base();
              if (best == null) return nullable ? Sys.ObjType.toNullable() : Sys.ObjType;
            }
              }
              if (best == null) best = Sys.ObjType;
              return nullable ? best.toNullable() : best;
        }