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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:14:14+00:00 2026-05-26T13:14:14+00:00

I created a array [Framework version 2.0, C# 2.0] that stores the months in

  • 0

I created a array [Framework version 2.0, C# 2.0] that stores the months in a year like so

source

public readonly static string[] Months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };

I am looking for a way to retrieve IEnumerable that returns a range of months from this static list. I can think of many ways but i am here to find one that makes me go wahhhhhh…
signature of the method would look something like

signature

public IEnumerable<String> GetRange(int startIndex,int endIndex);

sample I/O

startindex = 1
endindex = 10
returns months from January ,February,March upto October

note: Array.Copy is neat but the way parameters is used makes be go wacky

Parameters

sourceArray

    The Array that contains the data to copy.

sourceIndex

    A 32-bit integer that represents the index in the sourceArray at which copying begins.

destinationArray

    The Array that receives the data.

destinationIndex

    A 32-bit integer that represents the index in the destinationArray at which storing begins.

length

    A 32-bit integer that represents the number of elements to copy.
  • 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-26T13:14:14+00:00Added an answer on May 26, 2026 at 1:14 pm

    I would like to thank every single person who put their mind to answer my question – Thanks
    here is the code that worked for me using the Inhouse objects

    Fetches within the range

    public static IEnumerable<string> GetRange(short startIndex, short endIndex)
        {
            /*Cases
             * end > start
             * end > bounds
             * start < bounds
             * start != end
             */
            if (startIndex > endIndex || endIndex > Months.Length || startIndex < 0 || startIndex == endIndex)
            {
                throw new ArgumentOutOfRangeException("startIndex", "Invalid arguments were supplied for Start and End Index");
            }
            for (int rangeCount = startIndex-1; rangeCount < endIndex; rangeCount++)
            {
                yield return Months[rangeCount];
            }
        }
    

    Fetches from given index upto the end

    public static IEnumerable<string> GetFrom(int startIndex)
    {
        if (startIndex < 0 || startIndex > Months.Length - 1)
        {
            throw new ArgumentOutOfRangeException("startIndex", "Start Index cannot be greater than the Bounds of the months in year");
        }
    
        for (int rangeCount = startIndex - 1; rangeCount < Months.Length; rangeCount++)
        {
            yield return Months[rangeCount];
        }
    }
    

    i would like to know if i could use fetch within range method inside
    fetch from index method.

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

Sidebar

Related Questions

I have created an array Man: public main blah blah{ man = man[10]; }
I created a custom button component that accepts an array as a property. I
I created a program that more or less holds an array of strings as
I'm using Zend Framework version 1.7.8. I am trying to create a class that
I have a UTF-8 string (created an std::string from a byte array) I understand
The .Net framework has an Array.Sort overload that allows one to specify the starting
I'd like to write a small JavaScript (framework) that can chain functions with all
i have created Array of Linkbutton and when user click on link button it
I have an array created with this code: var widthRange = new Array(); widthRange[46]
I am trying to iterate a multidimension array created with the following line To

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.