更新时间:2022-04-15 02:36:58
是的-您只需要使用 Select
的重载,该重载采用 Func< TSource,int,TResult>
.因此,在C#中,它将类似于:
Yup - you just need to use the overload of Select
which takes a Func<TSource, int, TResult>
. So in C# it would be something like:
XDocument doc = new XDocument(new XElement("Types",
Assembly.GetExecutingAssembly().GetReferencedAssemblies()
.Select(name => Assembly.Load(name))
.SelectMany(assembly => assembly.GetTypes())
.Select((type, index) => new XElement("Type",
new XAttribute("ID", index + 1),
type.FullName))));
对不起,它不在VB中,但更可能以这种方式工作-希望您能完成翻译工作:)
Sorry it's not in VB, but it's more likely to work this way - hopefully you can work out the translation :)