这应该接近你想要的。不确定foreach中的DeleteSheets()应该做什么。如果我这样做,我也可以在那里提供帮助。 进行更改以将DeleteSheet函数作为参数。 This should be close to what you are looking for. Not sure what the DeleteSheets() in the foreach is supposed to do. If I did I might be able to help there too.Made changes to take the DeleteSheet func as a parameter.public Dictionary<T, bool> DeleteSheets<T>(List<T> sheets, Func<T, bool> delT) { Dictionary<T, bool> results = new Dictionary<T, bool>(); foreach (T s in sheets) results.Add(s, delT(s)); return results; } 只需用字母替换你想要通用的类型(约定是 T ): Just replace the type you want to be generic with a letter (the convention is T):public Dictionary<T, bool> DeleteSheets(List<T> sheets) { Dictionary<T, bool> results = new Dictionary<T, bool>(); foreach (T s in sheets) results.Add(s, DeleteSheet(s)); return results; } 这篇关于C#Generic - 转换此函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-25 06:22