Click here to Skip to main content
15,893,381 members

Comments by Alexandru Ghiondea (Top 16 by date)

Alexandru Ghiondea 5-Aug-11 14:31pm View    
You are correct! I was not aware of this - thanks! :)

Alex
Alexandru Ghiondea 5-Aug-11 14:00pm View    
The way the current solution is wrote, the same numbers will be generated every-time you run your app.

You should provide a seed to the Random number generator. I usually use (int)DateTime.Now.Ticks.

Thanks,
Alex
Alexandru Ghiondea 5-Aug-11 2:14am View    
That is the because a for loop works like this:
1. Initialize (you are assigning a constant of type int (0) to a variable of type a)
2. Check if condition is valid (you are, again, invoking the > operator with an integer (10) and a variable of type a).
3. Increment -> you have your own increment operator defined for a nybble.


For the first one, you are assigning an integer to a Nybble - so the correct implicit conversion kicks in. (The one from int to Nybble)

For the second one, you are using the < operator. The < operator works on operands of the same type. So it will convert 10 to the Nybble type and the call your < operator (the one defined on Nybble).

Alex
Alexandru Ghiondea 4-Aug-11 21:10pm View    
When the loop "loops" it has to verify that the value of a is smaller than 10. Because 10 is an integer, it will have to apply the implicit conversion from a (which is a Nybble) to int. So your operator gets called.

Does this explain it? If not, could you be more explicit about what your question is? What is it that you find wrong in the output?
Alexandru Ghiondea 3-Aug-11 13:21pm View    
What BobJanova said.

Alex