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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:46:15+00:00 2026-06-14T07:46:15+00:00

I recently discovered that structs in C# can have methods. Quite accidentally, I found

  • 0

I recently discovered that structs in C# can have methods.

Quite accidentally, I found myself to have been using the static method of an empty struct in my code, rather than the static method of a static class that I thought I was working with!

e.g.

public struct Foo
{
    public static void Bar(Param param)
    {
        ...
    }
}

It’s not really being used as a struct at this point, as it has no properties at all!

Is this very different from using a static method of a class (static or otherwise)? Are there any reasons to prefer one over the other? (My gut tells me that using the static struct method is, at minimum, less intuitive)

  • 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-06-14T07:46:16+00:00Added an answer on June 14, 2026 at 7:46 am

    No, static members belong to the type and not to instances of the type. There is no difference (neither with respect to performance nor semantics) between declaring static class members and static struct members.

    It is important to note that if a type’s only function is to contain static members, you should use a static class instead. With structs, there is an implicit and unchangeable public, no-argument constructor. If the type will not have any instance methods, the ability to create instances should be removed. Declaring a class static is the same as declaring it abstract sealed, so developers will not be able to accidentally create instances that have no purpose.

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

Sidebar

Related Questions

I recently discovered that a method in a derived class can only access the
I have recently discovered that I was using my third party diff/merge tool incorrectly
I have recently discovered that I can make windows executables with g++ that have
I'm using libsvm library in my project and have recently discovered that it provides
I recently discovered that all Windows 7 machines have an handwriting recognition API within
I recently discovered that when you have a page set to session readonly and
I recently discovered that I can use lambdas to create simple event handlers. I
I recently discovered that in C++ you can overload the function call operator, in
I have recently discovered that I am affected by this bug http://www.mail-archive.com/mono-bugs@lists.ximian.com/msg71515.html Well, at
Lately I've been tracking a spammer on craigslist. I recently discovered that he's added

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.