C
C#6mo ago
Mathall

How to set a variable = to itself + another variable

Hello, im completely new to C#, and still trying to learn the basics, I'm trying to create an average finder, and have all the users values be put into a list to be added together. However it's telling me that i cannot use the same variable as it is "an unassigned local variable", any help and tips would be appreciates
C#
for(int i = 0; i < numCount; i++) {
double preSum = preSum + numberList[i];
}
C#
for(int i = 0; i < numCount; i++) {
double preSum = preSum + numberList[i];
}
1 Reply
Mathall
MathallOP6mo ago
the second preSum is what is being called the unassigned local variable
Want results from more Discord servers?
Add your server