Click here to Skip to main content
15,909,829 members
Home / Discussions / C#
   

C#

 
QuestionRTF/Regex Question Pin
Mike Hankey9-May-07 15:59
mveMike Hankey9-May-07 15:59 
AnswerRe: RTF/Regex Question Pin
subrata.jana9-May-07 20:38
subrata.jana9-May-07 20:38 
GeneralRe: RTF/Regex Question Pin
Mike Hankey10-May-07 1:26
mveMike Hankey10-May-07 1:26 
Questionhelp...how to highlight buttons in c#? Pin
Missy Glory9-May-07 15:26
Missy Glory9-May-07 15:26 
AnswerRe: help...how to highlight buttons in c#? Pin
Vikram A Punathambekar9-May-07 18:01
Vikram A Punathambekar9-May-07 18:01 
AnswerRe: help...how to highlight buttons in c#? Pin
marky7779-May-07 21:00
marky7779-May-07 21:00 
AnswerRe: help...how to highlight buttons in c#? Pin
Leyu10-May-07 2:21
Leyu10-May-07 2:21 
QuestionSimple hashcode [modified] Pin
gumi_r@msn.com9-May-07 13:04
gumi_r@msn.com9-May-07 13:04 
Hi all,

I'm coding a small math library for an app we are developing. Its basically 3D math, Vectors, Matrix, etc.

I'm currently coding a struct Vector3D and I've overriden Equals(obj b) and was currently studying if I needed to override GetHashCode() or if the base implementation would work. A few simple tests proved that the default base implementation will not work as I'm getting same HashCodes for different Vectors and that's not good :p.

I'm not even sure I really need to implement a safe HashCode algorithm because I don't foresee the vector struct being used in such scenario, but still, I wouldn't like to leave something in my code that I know is not right. Never know how someone might consume the library in the future.

So my question is: Can somebody point me out how I should go about generating a unique int from 3 random doubles? My vector has obviously 3 coords, xyz and two vectors are the same only if all coords are the same which means that my GetHashCode() should generate a unique number for each combination of (x,y,z).

Any suggestions are welcome.

P.D. I'm not even sure if its possible to do. If I stop to think about it, you have a finite set of hashcodes you can generate (int.Min,int.Max) while the combination of diferent x,y,z coords is endless. Confused | :confused: Am I misunderstanding the point of GetHashCode()?



-- modified at 19:13 Wednesday 9th May, 2007
AnswerRe: Simple hashcode Pin
Luc Pattyn9-May-07 14:20
sitebuilderLuc Pattyn9-May-07 14:20 
GeneralRe: Simple hashcode [modified] Pin
gumi_r@msn.com9-May-07 22:33
gumi_r@msn.com9-May-07 22:33 
GeneralRe: Simple hashcode Pin
Luc Pattyn9-May-07 22:48
sitebuilderLuc Pattyn9-May-07 22:48 
GeneralRe: Simple hashcode [modified] Pin
gumi_r@msn.com9-May-07 23:02
gumi_r@msn.com9-May-07 23:02 
GeneralRe: Simple hashcode Pin
Luc Pattyn9-May-07 23:09
sitebuilderLuc Pattyn9-May-07 23:09 
QuestionRegular Expression for Getting file urls. Pin
Neo_Shehpar9-May-07 12:23
Neo_Shehpar9-May-07 12:23 
AnswerRe: Regular Expression for Getting file urls. Pin
Ed.Poore9-May-07 12:41
Ed.Poore9-May-07 12:41 
AnswerRe: Regular Expression for Getting file urls. Pin
zinc_z10-May-07 1:31
zinc_z10-May-07 1:31 
QuestionSharing an object in Assembly ? Pin
zinc_z9-May-07 11:59
zinc_z9-May-07 11:59 
AnswerRe: Sharing an object in Assembly ? Pin
Judah Gabriel Himango9-May-07 12:34
sponsorJudah Gabriel Himango9-May-07 12:34 
QuestionDeleting Leading White Spaces Pin
dboy2219-May-07 10:34
dboy2219-May-07 10:34 
AnswerRe: Deleting Leading White Spaces Pin
Giorgi Dalakishvili9-May-07 10:41
mentorGiorgi Dalakishvili9-May-07 10:41 
AnswerRe: Deleting Leading White Spaces Pin
Patrick Etc.9-May-07 10:44
Patrick Etc.9-May-07 10:44 
QuestionTrace messages from a service on 2003 Server not showing??!! Pin
LongRange.Shooter9-May-07 10:25
LongRange.Shooter9-May-07 10:25 
Question"Exception of type 'System.OutOfMemoryException' was thrown Pin
AAKAra9-May-07 10:14
AAKAra9-May-07 10:14 
AnswerRe: "Exception of type 'System.OutOfMemoryException' was thrown Pin
LongRange.Shooter10-May-07 10:12
LongRange.Shooter10-May-07 10:12 
QuestionSteps to developing a Proxy Server Pin
TheGecko9-May-07 9:18
TheGecko9-May-07 9:18 

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.