© 2026 Hedgehog Software, LLC

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

✅ `T` always value for `nameof`

        int id = nameof(T).GetHashCode();
        Console.WriteLine(nameof(T));
        int id = nameof(T).GetHashCode();
        Console.WriteLine(nameof(T));

how come
nameof(T)
nameof(T)
always returns
T
T
instead of the type of the generic argument?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Input value always comes ""
C#CC# / help
2y ago
✅ Purpose and use of nameof() keyword
C#CC# / help
12mo ago
✅ Is it possible to use nameof in attributes?
C#CC# / help
3y ago
Ensure there is always a value in NumericUpDown?
C#CC# / help
8mo ago