supose
int i=5;
or
int i=2,4;
in between the two statements one is true and other false .
what is the reasone.......
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Upamanyu Roy ChoudhuryPosted Feb 19, 2013, 1:27 PM
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
brunda kPosted Feb 19, 2013, 1:15 PM
VulpesPosted Feb 19, 2013, 9:26 AM
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;