Question

I am developing a Windows Form Application in VB .NET 4.0 and need to generate strings that are unique during the life of the application. I have come across the function "System.Guid.NewGuid.ToString" that seems to solve this problem, but I have read that there still can be "collisions" from time to time.

I could use a global counter variable, but I have had parameter scope issues with this in the past and would like to stay away from it if possible.

Any suggestions would be greatly appreciated.

Était-ce utile?

La solution

The probability of collision is so low that you could generate millions of GUIDs a second and only approach 1% collision chance after several (hundred) years.

This seems like an acceptable solution to me.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top