Click here to Skip to main content
16,004,540 members

Comments by George Swan (Top 200 by date)

George Swan 14-Sep-24 1:26am View    
You are very welcome. Your recursive method is excellent.
George Swan 8-Sep-24 17:06pm View    
That 'simple app' isn't very simple. It has recursive yield returns. Recursive algorithms can be difficult to figure out and the instances that have yield return statements are especially complex as you have to know the state of the variables inside the state machine that the yield return statement sets up. You have a lot of plates spinning there and you have done very well to keep them all up.
George Swan 7-Sep-24 4:38am View    
You need to include the Age property when building the hash value but there is no need to call its GetHash method. But with other values that are not integers you need to call the method as it returns an int.

Person myPerson = new() { Name = "Bob", Age = 35 };
int hashA=myPerson.Name.GetHashCode()+myPerson.Age;
int hashB= myPerson.Name.GetHashCode() + myPerson.Age.GetHashCode();
Console.WriteLine(hashA==hashB);//Writes 'True'
George Swan 6-Sep-24 16:02pm View    
The reason XOR is used in hashing is because the truth table yields an equal probability for both 1 and 0 being selected. AND is zero biased 3/1 OR is 1 biased 3/1. On a more pedantic point, the hash value of an integer is equal to its actual value so the call to Age.GetHash() is superfluous.
George Swan 9-Jul-24 13:36pm View    
I would suggest using PreviewMouseLeftButtonDown. It is a Tunnel event and they are more robust than bubble events.