Languages
[Edit]
EN

C# / .NET - default array values

0 points
Created by:
Elleanor-Williamson
380

In this article, we would like to show you what are default array values initialized by the compiler when you don’t assign values to array elements in C#.

Quick solution:

DatatypeDefault value

DatatypeDefault value
int0
double0.0
booleanfalse
char'\0' (U+0000)
stringnull
user-definednull

 

Practical example

Edit

In this example, we create one-element, not initialized arrays to see what is the default value for each type.

Output:

References

Edit
  1. Default values of C# types - C# reference | Microsoft Docs
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join