-1

I don't really get what the function of "+=" is.. Could someone explain it to me? Like what's the different between "=" and "+="

I've got something like this now: b +=(a[i]);

Thanks!

Kmel
  • 15
  • 3

3 Answers3

5

b = a assigns a to b
b += a assigns b+a to b

Ex:

int a = 5;
int b = 2;
b = a;  //b is now 5

vs.

int a = 5;
int b = 2;
b += a;  //b is now 7
Russell Steen
  • 6,494
  • 6
  • 38
  • 56
0
b +=(a[i]);

It is a shortcut for this

b = b + a[i];

https://msdn.microsoft.com/en-us/library/sa7629ew.aspx

Tim Freese
  • 435
  • 3
  • 14
0

b = a[i] + b

But you can use it for add event

Button.Click += new System.EventHandler(Button_Click);

Arnaud
  • 84
  • 1
  • 10