C# FAQ: Should calling Initialize on a reference type array fill it with objects

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
CSharp-Online.NET:FAQs
edit

Should calling Initialize() on a reference type array fill it with objects?

The Initialize() method of a System.Array class instance is designed to initialize value type arrays to their default values. But, it does not work on reference type arrays.

Actually, Initialize() is not designed for C# value type structs; because, C# structs cannot have default constructors which Initialize could call. Common Language Runtime (CLR) value types may have parameterless constructors; but in C#, there is no practical method of creating such a type.

See also


Personal tools