Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGavin McHugh
348 Pointswhat dose new string mean in C#
what dose new string mean in C#
1 Answer
Damien Watson
27,419 PointsThe keyword 'new' is used to Instantiate a class, it's saying "give me a new version of string[]". In the context you are describing, there is a class of type 'string' which is to be an array 'string[]'. You are setting the variable 'fields' to equal a new instance of it, initialising it with 4 items.
Any time you want to instantiate a class, you need to use 'new'. Does this help?
Gavin McHugh
348 PointsGavin McHugh
348 Pointsin this context when using arrays static string[] fields = new string[4];
Damien Watson
27,419 PointsDamien Watson
27,419 PointsUpdated the answer.