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
| CSharp-Online.NET:FAQs |
| edit |
[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.
[edit]
See also
- Does C# check array bounds? (array bounds checking)
- Does C# support jagged arrays?
- Should calling
Initialize()on a reference type array fill it with objects?