Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6587801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:57:53+00:00 2026-05-25T16:57:53+00:00

Is that possible to get current Enumerator (…or iterator? Don’t know which tern is

  • 0

Is that possible to get current Enumerator (…or iterator? Don’t know which tern is the correct one) in a LINQ query ?

For example, I try to create a XML output (via LINQ to XML) of all currently loaded assemblies.

Dim xmldoc As XDocument = New XDocument(
        New XElement("Types",
        Assembly.GetExecutingAssembly().GetReferencedAssemblies() _
                .Select(Function(name) Assembly.Load(name)) _
                .SelectMany(Function(assembly) assembly.GetTypes()) _
                .Select(Function(type) New XElement("Type", type.FullName))))

Tho output looks like this.

<Types>
  <Type>System.Object</Type>
  <Type>FXAssembly</Type>
  <Type>ThisAssembly</Type>
  <Type>AssemblyRef</Type>
  <Type>System.Runtime.Serialization.ISerializable</Type>
  <Type>System.Runtime.InteropServices._Exception</Type>
  .....
</Types>

is it possible to somehow get current “index” (counter?) from LINQ’s Selects? I would like to use it in XML

<Types>
  <Type ID="1">System.Object</Type>
  <Type ID="2">FXAssembly</Type>
  <Type ID="3">ThisAssembly</Type>
  <Type ID="4">AssemblyRef</Type>
  <Type ID="or-some-other-unique-id-#5">System.Runtime.Serialization.ISerializable</Type>
      .....
</Types>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:57:54+00:00Added an answer on May 25, 2026 at 4:57 pm

    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))));
    

    Sorry it’s not in VB, but it’s more likely to work this way – hopefully you can work out the translation 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does any one know if its possible to animate app.current.mainwindow.width so that you get
Over in this question, Scott writes that it is possible to get the current
I know that it's possible to get SVN to send emails after a commit
Is it possible to get the current URL that an IFrame is set to
I've seen that it's possible to get the latitude and longitude (geocoding, like in
Is it possible to get access to the spell checker that is incorporated in
Is it possible to get a reference to the triggerElement that invoked the Ajax
Is it possible to get the equivalent of the focus and blur events that
is it possible to get the last value of an string, that looks like
From Java, is it possible to get the complete commandline with all arguments that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.