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 6798891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:47:02+00:00 2026-05-26T18:47:02+00:00

Here is the java code i incompletely tried to translate static Enumeration enumerate() {

  • 0

Here is the java code i incompletely tried to translate

    static Enumeration enumerate()
    {
    Vector list = new Vector();
    Enumeration e = cache.keys();
    while (e.hasMoreElements())
    {
         Vector v = (Vector) cache.get(e.nextElement());
         for (int i = 0; i < v.size(); i++)
         {
         list.addElement(v.elementAt(i));
         }
    }
   return list.elements();
     }

This is the C# translation but not complete

    public static IEnumerable<Http> enumurate()
    {
        List<Http> list = new List<Http>();
        IEnumerator e = cache.Keys.GetEnumerator();
        while (e.MoveNext())/*While e has more element*/
        {
            var vector = (List<Http>)cache[e.Current];
            for (int i = 0; i < vector.Count; i++)
            {
                list.Add(vector.ElementAt<Http>(i));
            }
        }
        return //Something missing!!
    }

Any help please !

  • 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-26T18:47:03+00:00Added an answer on May 26, 2026 at 6:47 pm

    In C# List<Http> implements IEnumerable<Http> so you can simply return your list:

    return list;
    

    To convert the code to C# even more, you could just skip the adding of elements to the list and yield results directly:

    public static IEnumerable<Http> enumerate()
    {
        IEnumerator e = cache.Keys.GetEnumerator();
        while (e.MoveNext())/*While e has more element*/
        {
            var vector = (List<Http>)cache[e.Current];
            for (int i = 0; i < vector.Count; i++)
            {
                yield return vector.ElementAt<Http>(i);
            }
        }
    }
    

    Also, you can avoid using enumerators directly and make the code even more readable:

    public static IEnumerable<Http> enumerate()
    {
        foreach (var key in cache.Keys)
        {
            foreach (var http in (List<Http>)cache[key])
            {
                yield return http;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the Java code which I want to translate to C#: public Enumeration
here is the code (java): class prime { public static boolean prime (int a,
Here is my code: import javax.swing.*; import java.awt.*; public class PanelModel { public static
Here is a java code for breadth-first travel: void breadthFirstNonRecursive(){ Queue<Node> queue = new
I happen to come across a Java code at my work place. Here's the
Here is a simple piece of code: import java.io.*; public class Read { public
Here I found this code: import java.awt.*; import javax.swing.*; public class FunWithPanels extends JFrame
Here is the piece of code that I have used for Java 5.0 TreeSet<Integer>
Here is the code: import javax.swing.*; import java.awt.event.*; import java.awt.*; public class TestGrid {
Here is the code: import javax.swing.SwingUtilities; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JLabel; import java.awt.event.*;

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.