Click here to Skip to main content
15,927,803 members
Home / Discussions / C#
   

C#

 
GeneralRe: BinarySearch problem... Pin
Heath Stewart30-Sep-04 15:16
protectorHeath Stewart30-Sep-04 15:16 
GeneralRe: BinarySearch problem... Pin
Tesic Goran30-Sep-04 17:52
professionalTesic Goran30-Sep-04 17:52 
GeneralRe: BinarySearch problem... Pin
Heath Stewart1-Oct-04 14:38
protectorHeath Stewart1-Oct-04 14:38 
GeneralRe: BinarySearch problem... Pin
Tesic Goran2-Oct-04 14:36
professionalTesic Goran2-Oct-04 14:36 
GeneralDigicam wizard Pin
Alex Korchemniy30-Sep-04 11:18
Alex Korchemniy30-Sep-04 11:18 
GeneralDataGrid Custom Column Header Pin
ddelapasse30-Sep-04 10:44
ddelapasse30-Sep-04 10:44 
GeneralRe: DataGrid Custom Column Header Pin
Heath Stewart30-Sep-04 14:30
protectorHeath Stewart30-Sep-04 14:30 
GeneralRe: DataGrid Custom Column Header Pin
ddelapasse30-Sep-04 14:56
ddelapasse30-Sep-04 14:56 
GeneralRe: DataGrid Custom Column Header Pin
Heath Stewart1-Oct-04 14:36
protectorHeath Stewart1-Oct-04 14:36 
GeneralShortcut Manager Pin
pat27088130-Sep-04 10:11
pat27088130-Sep-04 10:11 
GeneralRe: Shortcut Manager Pin
Heath Stewart30-Sep-04 10:32
protectorHeath Stewart30-Sep-04 10:32 
GeneralRe: ProgressBar Pin
Heath Stewart30-Sep-04 10:28
protectorHeath Stewart30-Sep-04 10:28 
GeneralPerformance of DoubleBuffer in .NET Pin
Wizard_0130-Sep-04 9:41
Wizard_0130-Sep-04 9:41 
GeneralRe: Performance of DoubleBuffer in .NET Pin
Heath Stewart30-Sep-04 10:26
protectorHeath Stewart30-Sep-04 10:26 
GeneralRe: Performance of DoubleBuffer in .NET Pin
Wizard_0130-Sep-04 11:10
Wizard_0130-Sep-04 11:10 
GeneralRandom number in C# Pin
goatstudio30-Sep-04 8:01
goatstudio30-Sep-04 8:01 
GeneralRe: Random number in C# Pin
Dave Kreskowiak30-Sep-04 8:22
mveDave Kreskowiak30-Sep-04 8:22 
Simple. Your creating a new Random number generator with each invocation of .GetID() and in creating that generator, your seeding the RNG with the current time, in Ticks. What your doing is telling the new random number generator to start with the seed value and generate a REPRODUCABLE string of numbers. What you should be doing in your IDGenerator class is declaring a class level Random, initializing it once, and using it's .Next method on each call to .GetID().
public class IDGenerator
{
    int min, max;

    Random r = new Random(unchecked((int)DateTime.Now.Ticks));

    public IDGenerator ()
    {
        this.min = 1000000;
        this.max = 9999999;
    }

    public string GetID ()
    {
        // Produce a number from min through max.
        // Use the RNG created at the class level.
        String myNumber = r.Next(min,max).ToString("0000000");
        return myNumber;
    }
}

Also, random numbers are not guaranteed to be unique during the life of the generator, so review your policies on what this function will acceptibly return. It's entirely possible that it could return the same number twice (or more) in a row.


RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

GeneralRe: Random number in C# Pin
Nick Parker30-Sep-04 8:37
protectorNick Parker30-Sep-04 8:37 
GeneralNavigation in the same window for WebBrowser Control Pin
kayhustle30-Sep-04 6:52
kayhustle30-Sep-04 6:52 
GeneralRe: Navigation in the same window for WebBrowser Control Pin
Nick Parker30-Sep-04 8:10
protectorNick Parker30-Sep-04 8:10 
GeneralQuestion about .NET visual inheritance and MDI apps. Pin
rolst530-Sep-04 6:41
rolst530-Sep-04 6:41 
GeneralRe: Question about .NET visual inheritance and MDI apps. Pin
Heath Stewart30-Sep-04 6:55
protectorHeath Stewart30-Sep-04 6:55 
GeneralExcel Automation question Pin
sameerhanda30-Sep-04 6:33
sameerhanda30-Sep-04 6:33 
GeneralRe: Excel Automation question Pin
Heath Stewart30-Sep-04 6:46
protectorHeath Stewart30-Sep-04 6:46 
GeneralRe: Excel Automation question Pin
sameerhanda30-Sep-04 7:17
sameerhanda30-Sep-04 7:17 

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.