© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
68 replies
2spooky2play

✅ Get type of current instance in a static method

    public static int GetTypeId() {
        return typeof(TypeOfInstance).Name.GetHashCode();
    }
    public static int GetTypeId() {
        return typeof(TypeOfInstance).Name.GetHashCode();
    }

how can i get the current type of the current class? this class will be inherited by other classes, and i need to get the hash code of the name of the class
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

Calling static method of interface via it's type
C#CC# / help
16mo ago
object reference not set to instance of object on a static method call
C#CC# / help
3y ago
Calling a static abstract method without a generic type [Answered]
C#CC# / help
4y ago
Cannot access non-static method in static context?
C#CC# / help
4y ago