while (read_Email.Read())
{
email = read_Email.GetValue(i).ToString();
list_emails.Add(email);
i = i + 1 - 1;
}
what does the i = i + 1 - 1; mean? I know of +=, but i++,++i part is puzzling
1
Expert's answer
2016-09-02T10:23:04-0400
Provided snippet of code reading from email values with index of i.
i = i + 1 - 1; // This one is doing nothing. (variable i doesn't change it's value at every iteration)
What about difference between i++ and ++i: Each of them is iteration of variable. i++ gives same result as i = i + 1 or i += 1; ++i gives same result with only one difference: CALCULATION of it will be done before variable i will be getted or returned. This means for example: void Main() { int i; Console.WriteLine(GetIteration(out i)); Console.WriteLine(i); } public int GetIteration(out int i) { i = 4; return i++; } Result of this code above will be: 4 5 -------------------------------------------------------------- void Main() { int i; Console.WriteLine(GetIteration(out i)); Console.WriteLine(i); } public int GetIteration(out int i) { i = 4; return ++i; }
Result of this code above will be: 5 5 -------------------------------------------------------------- So, as you can see returned variable at second option was incremented before it was returned to invocation method.
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment