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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:09:02+00:00 2026-05-23T08:09:02+00:00

I have the following: public class Sort { public static void ShuffleGenericList<T>(IList<T> list) {

  • 0

I have the following:

public class Sort
{

    public static void ShuffleGenericList<T>(IList<T> list)
    {
        //generate a Random instance
        Random rnd = new Random();
        //get the count of items in the list
        int i = list.Count();

        ...
        ...
    }
}

Should my class also be static or is it okay with just the method being static?

  • 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-23T08:09:02+00:00Added an answer on May 23, 2026 at 8:09 am

    Marking classes as static is purely optional (if they don’t contain extension methods).

    In other words, a static class‘ members must also be static, but generally static members can be declared in any class:

    // doesn't compile:
    static class StaticClass { 
        void M() { }
    }
    
    // compiles:
    class JustClass { 
        static void M1() { }
        void M2() { }
    }
    

    From the common sense, you should (but don’t have to) mark class as static when:

    • it has no instance members;
    • is never supposed to be instantiated;
    • it is not intended to be used as variable, parameter or member type;
    • all of the above is true and you want to express it with a compiler-enforced constraint.

    For example, new Sort() might or might not make any sense in your code, depending on what’s in the class, etc. From the sample you provided, I think marking it static is the way to go.

    Note, though, that you have to mark class as static when it contains extension methods you intend to use in other parts of your code. Classes that contain extension methods must be static.

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

Sidebar

Related Questions

I have following code public class TEST { public static void main(String arg[]){ try
I have the following program import java.util.*; public class Test { public static void
I have the following code: public class DeserializeAndCompare { public static List<string> IntoXML() {
I have following class public class ButtonChange { private int _buttonState; public void SetButtonState(int
So I have the following: public class Singleton { private Singleton(){} public static readonly
Consider you have the following class public class OuterClass { ... private static class
following is the code listed in MainClass.java. public class MainClass { public static void
I have the following class: public class Data { static public SqlDataReader ExecutSql(string sql)
I have the following view model: Public Class MyViewModel Public Property SelectedIDs As List(Of
I have following entities: public class Product { [Key] public int Id{get;set;} //other properties

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.