Click here to Skip to main content
15,926,596 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Excel Automation question Pin
Heath Stewart30-Sep-04 7:54
protectorHeath Stewart30-Sep-04 7:54 
GeneralRe: Excel Automation question Pin
sameerhanda30-Sep-04 8:12
sameerhanda30-Sep-04 8:12 
GeneralRe: Excel Automation question Pin
Heath Stewart30-Sep-04 10:13
protectorHeath Stewart30-Sep-04 10:13 
GeneralRe: Excel Automation question Pin
sameerhanda30-Sep-04 11:08
sameerhanda30-Sep-04 11:08 
Generalpictures in textboxes Pin
vyki_c30-Sep-04 6:22
vyki_c30-Sep-04 6:22 
GeneralRe: pictures in textboxes Pin
Heath Stewart30-Sep-04 6:40
protectorHeath Stewart30-Sep-04 6:40 
GeneralReal Time Applications Pin
sreejith ss nair30-Sep-04 6:03
sreejith ss nair30-Sep-04 6:03 
GeneralRe: Real Time Applications Pin
Dave Kreskowiak30-Sep-04 7:25
mveDave Kreskowiak30-Sep-04 7:25 
GeneralRe: Real Time Applications Pin
sreejith ss nair30-Sep-04 7:30
sreejith ss nair30-Sep-04 7:30 

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.