im not sure why this isnt working, Im just passing a blank string and a number and it should check if that number is in the string, if not then it should add it into the string.the variable ‘thing’ gets set but the global variable that it is supposed to update(strduplicates) is never updated.
I call the function like this
Trackstats(strduplicates,”1337″);
private void TrackStats(string thing, string variable)
{
if (!(thing.Contains(variable)))
{
thing += variable + ",";
}
}
You are passing
thingby value. You need to pass it by reference to make changes visible outside the method: