Well no, it won't necessarily work, and it won't necessarily exit. Ever.
The problem is that what you are building is not a valid suduko puzzle. Think of it this way:
If you are building a three by three suduko (instead of your 9 by nine) and the first row comes out as:
1 2 3
A perfectly valid start for line 2 is:
2 1 x
but there is no value you can put in place of the "x" - so your code will just loop round and round and round generating the random digits '1', '2' and '3' over and over again, but being unable to insert any of them, or exit your
loop until it has.
Because the problem is not in the value of 'x' - it is in the selected values before it which it can't change.
You cannot generate valid suduko puzzles just by generating a random number and making it fit! Try googling for "c# suduko generator" - it's quite a bit more complicated than you think!
I did tell you yesterday that using random number was not a good idea, didn't I?