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

  • Home
  • SEARCH
  • 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 6965555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:04:35+00:00 2026-05-27T16:04:35+00:00

I have this method which return an array of string : private static string[]

  • 0

I have this method which return an array of string :

    private static string[] ReturnsStringArray()
    {
        return new string[]
        {
            "The path of the ",
            "righteous man is beset on all sides",
            "by the inequities of the selfish and",
            "the tyranny of evil men. Blessed is",
            "he who, in the name of charity and",
            "good will, shepherds the weak through",
            "the valley of darkness, for he is",
            "truly his brother's keeper and the",
            "finder of lost children. And I will ",
            "strike down upon thee with great",
            "vengeance and furious anger those",
            "who attempt to poison and destroy my",
            "brothers. And you will know my name",
            "is the Lord when I lay my vengeance", 
            "upon you"
        };
    }
}

I want to write a method which use this method. As this method returns an array and not a IEnumerable, is there the same result to write this :

    private static IEnumerable<string> ParseStringArray()
    {
        return ReturnsStringArray()
            .Where(s => s.StartsWith("r"))
            .Select(c => c.ToUpper());
    }

and this :

    private static List<string> ParseStringArray()
    {
        return ReturnsStringArray()
            .Where(s => s.StartsWith("r"))
            .Select(c => c.ToUpper())
            .ToList(); // return a list instead of an IEnumerable.
    }

Thank you.

EDIT

My question is : Is there any interest or benefits that the method ParseStringArray() returns an IEnumerable instead of a List because of this method calls ReturnsStringArray that returns an array of string and not a IEnumerable

  • 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-27T16:04:35+00:00Added an answer on May 27, 2026 at 4:04 pm

    When you return a List, you are saying that “all processing has been done, and the List contains the results”.

    However, when you return an IEnumerable, you are saying that “processing might still need to be done”.

    In your example, when you return an IEnumerable, the .Where and .Select have NOT bee processed yet. This is known as “deferred execution”.
    If the user uses the result 3 times, then the .Where and .Select will execute 3 times. There are a good number of tricky issues that can come from this.

    I recommend using a List as often as possible when returning values from a method. In addition to the additional functionality you’ll get from a List, .NET has many optimizations that require a List, debugging support is better, and there’s a reduced chance of unintended side effects!

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

Sidebar

Related Questions

I have this recursive method which deletes empty folders: private void DeleteEmpty(DirectoryInfo directory) {
i have an string data array which contains data like this 5~kiran 2~ram 1~arun
i have a simple asmx page with one web method which return array of
I have this method Verify_X which is called during databind for a listbox selected
I have this code: s(x => x.Open()); s is a method which calls one
I have a method which runs this: Track* track = [[Track alloc] init:[obj objectForKey:@PersistentID]
I have a method, which uses random samples to approximate a calculation. This method
I have an interface called Dictionary which has a method insert() . This interface
I have a Jtable on which I called the method table1.setAutoCreateRowSorter(true); . So this
Example: I have a selector like this, which I give to another method as

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.