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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:28:46+00:00 2026-05-17T02:28:46+00:00

Given my current extension method: public static List<char> rotate(this List<char> currentList, int periodes) {

  • 0

Given my current extension method:

public static List<char> rotate(this List<char> currentList, int periodes) {
    if (periodes != 1) {
        int x = currentList.Count() - 1;
        return rotate(currentList.Skip(x).
             Concat(currentList.Take(x)).ToList<char>(), periodes - 1);
    }
    return currentList;
}

Original State:

ring = new List<char>() { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };

Current Result for ring.rotate(10);

J A B C D E F G H I
I J A B C D E F G H
H I J A B C D E F G
G H I J A B C D E F
F G H I J A B C D E      Recursive Steps
E F G H I J A B C D
D E F G H I J A B C
C D E F G H I J A B
B C D E F G H I J A

A B C D E F G H I J      Result

Is there any way to get rid of this while loop and any chance to integrate the repetition into the LINQ query?

Best
Henrik

  • 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-17T02:28:47+00:00Added an answer on May 17, 2026 at 2:28 am

    Skip i and concat i

    public static class Ex
    {
        public static List<char> Rotate(this List<char> c, int i)
        {
            i %= c.Count;
            return c.Skip(i).Concat(c.Take(i)).ToList();
        }
    }
    
    class Program
    {
        static void Main()
        {
            List<char> chars = new List<char>();
    
            for (int i = 65; i < 75; ++i)
            {
                chars.Add((char)i);
            }
    
            var r1 = chars.Rotate(10); // A B C D E F G H I J
            var r2 = chars.Rotate(1); // B C D E F G H I J A
            var r3 = chars.Rotate(101); // B C D E F G H I J A
            var r4 = chars.Rotate(102); // C D E F G H I J A B
    
            Console.ReadLine();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an extension method for an ASP.NET MVC ViewPage, e.g: public static
I need to get the current context given an entity I found this old
I am attempting to get the current weather given a zip code or a
So I have function that formats a date to coerce to given enum DateType{CURRENT,
I was given the task of doing a facelift to our current site. I
I have a function that get the current weeknumber from the given date e.g.
I have been given the following request. Please give 7% of the current contacts
What's the best possible way to find a given div.myClass element in the current
How can I print the next year if the current year is given in
How does a plugin add a page to the current WordPress theme a given

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.