Below is my code:
string str = ""
double totalCost = getCost(12.5. 20.2, str);
console.WriteLine(str) // print nothing here
and the getCost function is
double getCost(double inputA, double inputB, string nameofType) {
if(...){
nameofType = "xxx";
} else if (...) {
nameofType = "xxx";
} else {
nameofType = "xxx";
}
}
I know string get passed in functions, so inside getCost
function, one condition is always met, so the string will point to the new value, so why when I use Console.WriteLine to check the string str was still "", looks like it hasn't been changed?