I can't understand this in C#, despite looking for similar questions and answers.
I have an object cCar (class Car) with ID = 0. I passed this object to a method called CreateCarInDB from my class CarManager without using the ref word :
public static void CreateCarInDB(Car p_cCar)
{
int newId = CarDB.SaveNewCar(p_cCar);
p_cCar.ID = new Id;
}
I just want to understand why after executing the method, if i look, the cCar object has its Id = 1 for example. Shouldn't I use the word ref before method parameter so that this value is affected outside the method? I thought I was only passing the value and not the reference.
It doesn't seem I need to use the word ref.