© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•13mo ago•
16 replies
Faker

{} vs [] when initializing an array in C#

Hello guys, is there a difference when we use
{}
{}
to initialize an array or if we use
[]
[]
? I read that the
[]
[]
is known as a collection expression.

string[] orders = {"B123", "C234", "A345", "C15", "B177", "G3003", "C235", "B179"};

vs

string[] orders = ["B123", "C234", "A345", "C15", "B177", "G3003", "C235", "B179"];
string[] orders = {"B123", "C234", "A345", "C15", "B177", "G3003", "C235", "B179"};

vs

string[] orders = ["B123", "C234", "A345", "C15", "B177", "G3003", "C235", "B179"];
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

C++ struct initializing in C#
C#CC# / help
3y ago
✅ NullReferenceException when declaring an array but not initializing it
C#CC# / help
13mo ago
❔ Initializing an object
C#CC# / help
3y ago
Properties vs Fields in C#
C#CC# / help
13mo ago