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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:25:09+00:00 2026-05-26T09:25:09+00:00

Is there a way to assign a default method to a class like this:

  • 0

Is there a way to assign a default method to a class like this:

public class EscMenu
{
    public static void EscMenu()
    {
        //do something
    }

   public static void SomeOtherMethod()
   {
       //do something else
   }
}

So when I call EscMenu.SomeOtherMethod(); in another class in the same solution, it does “do something else”, but I cannot call EscMenu();.

How can I do that?

Thanks!

EDIT:

Okay, Im gonna try to explain this in a better way:

I just want the class EscMenu to do something when I call it from another (external) class like this: EscMenu();. Of course I could easily create a method default() in EscMenu and call EscMenu.default(); externally. But I would really like to just call EscMenu();

If that just isn’t possible or I continue to fail in explaining myself, then just don’t mind 😉

Thanks again!

  • 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-26T09:25:09+00:00Added an answer on May 26, 2026 at 9:25 am

    No, you can’t give a method the same name as its containing type – and you really don’t want to confuse the name of a type with the name of a method anyway. Why introduce the ambiguity?

    If you could give some example where you want to write code in some way other than what’s already available, we may be able to help you more. (For example, it may be that extension methods could help.)

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

Sidebar

Related Questions

Is there a way to have a default (something I were to assign) template
Is there an easy way in Visual Studio to assign default usings when i
Is there a way in MySQL table to assign a default when a value
Is there a way to assign a default values to arrays in javascript? ex:
I've a situation like this: class MyClass { private: std::auto_ptr<MyOtherClass> obj; public: MyClass() {
Is there a way to assign a process to a core (or more than
Is there a single-expression way to assign a scalar to all elements of a
is there way how to get name ov event from Lambda expression like with
I read this question here: Is there a way to override the empty constructor
I'd like to assign anonymous functions to arrays in PHP inside of a class,

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.