This documentation is archived and is not being maintained.

FormatterServices.GetUninitializedObject Method

Creates a new instance of the specified object type.

[Visual Basic]
Public Shared Function GetUninitializedObject( _
   ByVal type As Type _
) As Object
public static object GetUninitializedObject(
 Type type
public: static Object* GetUninitializedObject(
 Type* type
public static function GetUninitializedObject(
   type : Type
) : Object;


The type of object to create.

Return Value

A zeroed object of the specified type.


Exception Type Condition
ArgumentNullException The type parameter is a null reference (Nothing in Visual Basic).
SecurityException The caller does not have the required permission.


Because the new instance of the object is initialized to zero and no constructors are run, the object might not represent a state that is regarded as valid by that object. The current method should only be used for deserialization when the user intends to immediately populate all fields. It will not create an uninitialized string, since creating an empty instance of an immutable type serves no purpose.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

FormatterServices Class | FormatterServices Members | System.Runtime.Serialization Namespace