What is the difference between these two methods? Using params or just doing everything in one class

Bbialasik__11/17/2022
public static void Main(string[] args) {
  int a = 2, b = 3;
  int sum = Add(a, b)
}

public static int Add(int a, int b) {
  return a + b;
}
//5 variables


public static void Main(string[] args) {
  int a = 2, b = 3;
  int sum = a + b;
}
//3 variables

i just learned this in class and dont get why this is a thing
AAngius11/17/2022
Having a separate method allows you to reuse it
AAngius11/17/2022
It's not as visible with just doing addition inside, but if you were doing some more complex operations, it's very useful
Bbialasik__11/17/2022
makes sense
Bbialasik__11/17/2022
ty
Ttrunksvn11/18/2022
we usually only create a method, when you know you'll need to use the code again
AAccord11/22/2022
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.