Click here to Skip to main content
15,914,160 members
Home / Discussions / C#
   

C#

 
AnswerRe: Capture console output Pin
S. Senthil Kumar22-Nov-05 5:57
S. Senthil Kumar22-Nov-05 5:57 
GeneralRe: Capture console output Pin
Kash22-Nov-05 23:40
Kash22-Nov-05 23:40 
QuestionHow to playback file wave by tapi Pin
sharapova22-Nov-05 4:51
sharapova22-Nov-05 4:51 
QuestionHash Code calculation Pin
J4amieC22-Nov-05 4:20
J4amieC22-Nov-05 4:20 
AnswerRe: Hash Code calculation Pin
Stanciu Vlad22-Nov-05 6:08
Stanciu Vlad22-Nov-05 6:08 
GeneralRe: Hash Code calculation Pin
J4amieC22-Nov-05 6:23
J4amieC22-Nov-05 6:23 
GeneralRe: Hash Code calculation Pin
Stanciu Vlad22-Nov-05 7:40
Stanciu Vlad22-Nov-05 7:40 
GeneralRe: Hash Code calculation Pin
Leslie Sanford22-Nov-05 9:57
Leslie Sanford22-Nov-05 9:57 
J4amieC wrote:
Now, I had thought of concatenating the 4 values into a string and calling GetHashCode() on that string, but i thought this was a bit of a kludge... I guess i was getting too snmart for my bootsBig Grin | :-D


Are string hash codes guaranteed to be unique? I don't know the answer to that, but I'm guessing no.

Just wanted to point out that the solution Vlad described was not to concatenate strings but to bit-shift and OR together your ids. This guarentees uniqueness, but whether or not it's doable depends on the range of your ids.

J4amieC wrote:
I now think its a better solution, but if any math-heads out there know the real solution id be interested to hear.


Creating good hash codes seems to be an art in and of itself, kind of like creating good psuedo random number generators. I don't know much about this field, but I believe a good hash code algorithm will generally give values that are evenly distributed. They don't necessarily have to be unique.

This is why if you override GetHashCode, it's recommended (required?) that you override Equals as well. That's so if a duplicate hash code is encountered, Equals can be used to find the actual item. Though, I can understand wanting to avoid duplicates for performance reasons.

At any rate, you may know all of this, just chiming in with my two cents. Smile | :)

[EDIT]
Actually, after rereading Vlad's post, it looks like what he describes in the first paragraph does use string concatenation to create unique keys. An interesting approach.

In the second paragraph, I'm assuming he's talking about bitwise operations instead of string concatenation. At any rate, both approaches look ok to me. Smile | :)
[/EDIT]




-- modified at 16:03 Tuesday 22nd November, 2005
Questionapplication version (major and minor) c# winform Pin
fady_sayegh22-Nov-05 2:34
fady_sayegh22-Nov-05 2:34 
AnswerRe: application version (major and minor) c# winform Pin
Dan Neely22-Nov-05 3:06
Dan Neely22-Nov-05 3:06 
AnswerRe: application version (major and minor) c# winform Pin
J4amieC22-Nov-05 3:17
J4amieC22-Nov-05 3:17 
Question.NET 1.x remoting hell! Pin
Bob Stanneveld22-Nov-05 2:32
Bob Stanneveld22-Nov-05 2:32 
AnswerRe: .NET 1.x remoting hell! Pin
S. Senthil Kumar22-Nov-05 3:56
S. Senthil Kumar22-Nov-05 3:56 
GeneralRe: .NET 1.x remoting hell! Pin
Bob Stanneveld22-Nov-05 22:43
Bob Stanneveld22-Nov-05 22:43 
QuestionEval equivalent in C# Pin
zaboboa22-Nov-05 2:11
zaboboa22-Nov-05 2:11 
AnswerRe: Eval equivalent in C# Pin
Joshua Quick22-Nov-05 7:41
Joshua Quick22-Nov-05 7:41 
QuestionListen to serial port and read RFID kit Pin
Tyler4522-Nov-05 2:08
Tyler4522-Nov-05 2:08 
Questiondwg files to emf format Pin
theladsmith22-Nov-05 1:59
theladsmith22-Nov-05 1:59 
QuestionTips on how to handle Source Contol Pin
anderslundsgard21-Nov-05 23:21
anderslundsgard21-Nov-05 23:21 
AnswerRe: Tips on how to handle Source Contol Pin
mav.northwind22-Nov-05 2:00
mav.northwind22-Nov-05 2:00 
GeneralRe: Tips on how to handle Source Contol Pin
anderslundsgard24-Nov-05 4:36
anderslundsgard24-Nov-05 4:36 
GeneralRe: Tips on how to handle Source Contol Pin
mav.northwind24-Nov-05 7:44
mav.northwind24-Nov-05 7:44 
GeneralRe: Tips on how to handle Source Contol Pin
anderslundsgard24-Nov-05 23:28
anderslundsgard24-Nov-05 23:28 
QuestionProblem in running addins Pin
nbobby21-Nov-05 23:04
nbobby21-Nov-05 23:04 
AnswerRe: Problem in running addins Pin
S. Senthil Kumar22-Nov-05 4:00
S. Senthil Kumar22-Nov-05 4:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.