supose
int i=5;
or
int i=2,4;
in between the two statements one is true and other false .
what is the reasone.......
Why only one value is stored in one variable?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Feb 19, 2013, 4:26 AM EST
int i = 2,4;
is illegal because you can't assign two integer values to the integer variable 'i' at the same time.
However, you could do this:
int i = 2;
i = 4; // value of i changed to 4
// or declare and initialize two variables in the same statement:
int i = 2, j = 4;
brunda kRank #3,804 · 389 reputationPosted Feb 19, 2013, 8:15 AM EST
Upamanyu Roy Choudhury146 reputationPosted Feb 19, 2013, 8:27 AM EST
C# compiler will show an error for the second statement as it is not syntactically correct.
We cannnot assign multiple values in a single value type variable.
int i=2,4;
it will give an erro like the following
Error 1 Identifier expected c:\users\rajarshi\documents\visual studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs 23 21 WindowsFormsApplication1
So what we can do is that we can use an array,structure or collection class to hold multiple values.
If you find my post as useful please mark it as an answer