© 2026 Hedgehog Software, LLC

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

✅ Declaring and initializing multiple values in a single line in C#

Hello guys, consider the following statement:

int monsterHealth, heroHealth = 0;
int monsterHealth, heroHealth = 0;


If I write this code, heroHealth is assigned to 0, will this also assign monsterHealth to 0?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

C++ struct initializing in C#
C#CC# / help
3y ago
❔ Adding list in single line
C#CC# / help
3y ago
{} vs [] when initializing an array in C#
C#CC# / help
13mo ago
✅ NullReferenceException when declaring an array but not initializing it
C#CC# / help
13mo ago