Click here to Skip to main content
15,916,180 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a function which has params as an argument to it, so that it can take as many and any type of input. This function needs to give as output, an integer which is unique to the set of inputs received.

So to summarize, if it receives a different set of params it needs to generate a different integer, however if it receives same set of params if needs to give the same int again.

C#
private int GetUniqueValue(params object[] input)
        {
             //return a unique integer
        }


What I have tried:

I was thinking in terms of hashcode and using GetHashCode method but then msdn says that "The default implementation of the GetHashCode method does not guarantee unique return values for different objects"
Posted
Comments
Karthik_Mahalingam 1-Aug-16 2:04am    
what is your input and expected output?
Jameel VM 1-Aug-16 17:46pm    
Use guid instead of GetHashcode. Guid guid=Guid.NewGuid();it will generate a unique id

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900