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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:55:04+00:00 2026-05-29T10:55:04+00:00

I have written the following code to find out the missing sequence but i

  • 0

I have written the following code to find out the missing sequence but i am getting the error as i mentioned this is my code

public partial class Missing : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
    List<int> daysOfMonth =
       new List<int>() { 6, 2, 4, 1, 9, 7, 3, 10, 15, 19, 11, 18, 13, 22, 24, 20, 27, 31, 25, 28 };
    Response.Write("List of days:");
    foreach (var num in daysOfMonth)
    {
        Response.Write(num);
    }
    Response.Write("\n\nMissing days are: ");
    // Calling the Extension Method in the List of type int 
    foreach (var number in daysOfMonth.FindMissing()){Response.Write(number);}
}
public static IEnumerable<int> FindMissing(this List<int> list)
{
    // Sorting the list
    list.Sort();
    // First number of the list
    var firstNumber = list.First();
    // Last number of the list
    var lastNumber = list.Last();
    // Range that contains all numbers in the interval
    // [ firstNumber, lastNumber ]
    var range = Enumerable.Range(firstNumber, lastNumber - firstNumber);
    // Getting the set difference
    var missingNumbers = range.Except(list);
    return missingNumbers;
}

}

I am getting the error as follows Extension method must be defined in a non-generic static class can any one help me

  • 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-29T10:55:05+00:00Added an answer on May 29, 2026 at 10:55 am

    As the error states, extension methods can only be declared on a non-generic static class. You are attempting to declare the FindMissing method in the Missing class, which is not a non-generic static class.

    You have two options:

    1. Make the method a normal method, in which case it can stay in the Missing class
    2. Declare another class, perhaps MissingExtensions, to contain the method

    This is what the second option would look like:

    public static class MissingExtensions
    {
        public static IEnumerable<int> FindMissing(this List<int> list)
        {
            // ...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written the following code. But it is removing only &nbsp; not <br>
In physics library written in C# I have the following code: (in ContactManager.cs) public
This may well have come up before but the following code is taken from
I have written a following code to get just the file name without extension
I have written the following code choice /m Do you want to add another
i have written the following code: As you can see there is a for
I have written the following IronPython code: import clr clr.AddReference(System.Drawing) from System import *
I have written my code in following way in cocos2d. id actionTo = [CCFadeOut
I have string which is of format: ;1=2011-10-23T16:16:53+0530;2=2011-10-23T16:16:53+0530;3=2011-10-23T16:16:53+0530;4=2011-10-23T16:16:53+0530; I have written following code to
For an assignment, i have written the following code in recursion. It takes a

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.