Created
September 17, 2016 01:29
-
-
Save nbxx/3c360132e7c072356110bd5797602d79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static object CreateInstance(Type source, params object[] args) | |
{ | |
if (source == typeof(string)) | |
{ | |
return string.Empty; | |
} | |
object result = null; | |
try | |
{ | |
result = Activator.CreateInstance(source, args); | |
} | |
catch | |
{ | |
result = FormatterServices.GetUninitializedObject(source); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment