What is the difference between
private void DoSomething(int value) {
value++;
}
and
private int DoSomething(int value)
Everyone else seems to be suggesting the difference in variable passing, but I noticed something different:
If the example code you are displaying is a simplification of something you are already looking at, then you might want to note that in your second example:
private int DoSomething(int value) {
return value++;
}
The value will return then increment. So if you do the following:
public Main() {
int val = 1;
Console.writeln(DoSomething(val));
}
Your output will be 1.
Let me know if this helps at all.