即時通訊不知道爲什麼這不工作,我只是傳遞一個空白字符串和一個數字,它應該檢查如果該數字是在字符串中,如果不是,那麼它應該將它添加到字符串中。變量'thing'被設置,但它應該更新(strduplicates)的全局變量永遠不會被更新。字符串函數不更新全局變量
我稱之爲這樣的功能 Trackstats(strduplicates,「1337」);
private void TrackStats(string thing, string variable)
{
if (!(thing.Contains(variable)))
{
thing += variable + ",";
}
}
通過設計。使它成爲'ref string thing'。 – 2012-01-16 09:32:43
請參閱http://stackoverflow.com/questions/1096449/c-sharp-string-reference-type – nulltoken 2012-01-16 09:33:56
感謝它的工作! – Batista 2012-01-16 09:38:20