在C# Function中,要傳遞不同數量的參數可以用 參數 params 與 陣列 來協助
static string Combine(params string[] paths){
string result = string.Empty;
foreach(string path in paths){
result = System.IO.Path.Combine(result,path);
}
return resulr;
}
如此 在引用此Function時 就可不限制 參數 數量來使用
string fullName = combine(new string[]{"c:\","HStech","Review","Review.exe"});
全站熱搜