© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•8mo ago•
49 replies
MechWarrior99

How to generate a unique int from an arbitrary string?

I have strings of property names I am doing comparisons against, and realized ints would be much better to use for both performance and GC.

But I can't think of a good way to do it such that the same strings always generate the same ints, and that the ints are not duplicated, and is thread safe.

All I can think of is to just using a dictionary with a incremented int. Is there a better clever way of doin it?
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

Similar Threads

How to make string to int
C#CC# / help
3y ago
✅ how to generate an executable from a csharp code
C#CC# / help
2y ago