System.ZXParser.CreateDefaultFromType C# (CSharp) Method

CreateDefaultFromType() private static method

private static CreateDefaultFromType ( Type t ) : object
t Type
return object
        private static object CreateDefaultFromType(Type t)
        {
            if(t.IsValueType)
                return System.Runtime.Serialization.FormatterServices.GetUninitializedObject(t);
            ConstructorInfo ci = t.GetConstructor(System.Type.EmptyTypes);
            if(ci == null) throw new Exception("This Type Must Have A Constructor That Takes Zero Parameters");
            return ci.Invoke(null);
        }