Generating a Random Number

I recently had a need to generate a Random number within a certain range…. i came up with this, hope you find it useful!

        private int RandomNumber(int from = 0, int to = int.MaxValue)
        {
            RNGCryptoServiceProvider rngCsp = new RNGCryptoServiceProvider();
            bool Pass = false;
            int passNumber = 0;
            do
            {
                byte[] randomNumber = new byte[1];
                rngCsp.GetBytes(randomNumber);
                passNumber = randomNumber[0];
                if (passNumber >= from && passNumber <= to)
                {
                    Pass = true;
                }
            } while (Pass == false);
            return passNumber;
        }

78 Comments

  1. Another option to have a secure home is to change
    your lock rather than install a new. Usually a security code is used to open these kinds
    of locks. With a very good background to its credit, you will surely have a rewarding and ingenuous
    experience with a locksmith.

    Also visit my homepage – מסגרים

  2. Since then, the design of locks has advanced and incorporated new materials, such as steel, plastic, and other synthetic materials.

    • Don’t forget to check its compatibility with your building structure and
    the ability of the system to deliver a good sound quality which depends on the structure of your home.
    These companies may present specialized talent
    and gear needed for the work.

    Feel free to surf to my homepage … מעקות בהרצליה פיתוח

  3. This is very interesting, you are a very experienced blogger.
    I have joined your rss feed and look forward to reading more
    of your fantastic post. In addition, I have shared your website in my social networks!

    Feel free to surf to my page :: dentist family (Dario)

  4. No host is actually 99.99 % best right here. Nevertheless, all hosts ranked 4 stars or more
    are in the leading entertainers regarding uptime.

    Feel free to visit my website :: Stefanie

  5. Unquestionably believe that which you stated. Your favorite reason appeared to be on the web the simplest thing to
    be aware of. I say to you, I certainly get annoyed while people think
    about worries that they plainly don’t know about.

    You managed to hit the nail upon the top and also defined out the whole thing without having side-effects , people can take a
    signal. Will probably be back to get more. Thanks

    Visit my page :: http://www.youtube.com

  6. They can also provide you the total security systems installation for your residential or commercial purposes.
    • Don’t forget to check its compatibility with your building structure and the ability of the system
    to deliver a good sound quality which depends on the structure of your home.
    This is one of the miracles an auto locksmith can perform.

    Stop by my web-site: מסגר בהרצליה

  7. Maps, Addresses and Driving Directions to important places such
    as: Local Hospital Emergency Medical or “Walk-In” Clinics;
    Bank, ATM and Money Exchange; Airport, Train Station,and Bus Stations; Post Office,
    Fed – Ex, UPS or other Express Mailing Businesses; Grocery Stores,
    Butcher, Baker, Liquor Stores, or other Essential Stores;
    Internet Café or Business Center; Recommended Restaurants, Cafes, Clubs,
    or Thoroughfares; Local Places of Worship with phone numbers.
    In addition, you might need to have an electronic key replaced and a locksmith can also perform this service.
    Keep away from any company which has a huge amounts of problems.

    Feel free to surf to my web site … סורגים בהרצליה

  8. Victor worked for Aspen Commercial Security
    and has been continually grateful for the knowledge they have
    shared with him. ‘ Locksmiths can also give
    genuine suggestions on the kind of security systems which
    should be installed. Are you looking for an effective way
    to protect your family and your home.

    my blog מסגריה בהרצליה | מסגר מסגריות או מסגרים בהרצליה והרצליה פיתוח

  9. I loved as much as you’ll receive carried out right here. The sketch is attractive, your authored material stylish.
    nonetheless, you command get bought an shakiness over that you wish be
    delivering the following. unwell unquestionably come further formerly again since
    exactly the same nearly very often inside case you shield this hike.

  10. Bramah manufactures locks for domestic and commercial use.

    In addition, you might need to have an electronic key replaced and a locksmith can also perform this
    service. Services include lock changes, lock change,
    lock replacement, lock rekeying, security safes, grilles and gates and gates.

    Here is my web page … מסגריה בהרצליה | מסגר מסגריות או מסגרים בהרצליה והרצליה פיתוח

  11. What’s up to every body, it’s my first visit of this weblog; this webpage carries awesome and genuinely excellent stuff in favor of readers.

    Look into my web page: Corine

  12. Victor worked for Aspen Commercial Security and has been continually grateful for
    the knowledge they have shared with him. It’s possible you’ll even search for evaluations online.
    This is one of the miracles an auto locksmith can perform.

    my webpage; מסגרים

  13. It is easy for colors to bleed together in the dark,
    which makes spotting enemies much harder. As Dan Morris,
    Director of Game Partnerships for Facebook, put it, ‘The connection that people feel over a
    digital game is very real. However, once you hit a level 6 to above Town Hall level base you might want to combine archers with
    other troops such as giants or wallbreakers.

  14. hey there and thank you for your info – I have definitely picked up anything new from right here.
    I did however expertise a few technical points using this site,
    since I experienced to reload the web site a lot of times previous to I could get it to load correctly.
    I had been wondering if your hosting is OK?

    Not that I’m complaining, but sluggish loading instances times will sometimes affect your placement in google and
    could damage your quality score if ads and marketing with Adwords.
    Anyway I’m adding this RSS to my e-mail and could look out
    for much more of your respective intriguing
    content. Ensure that you update this again soon.

    my page :: boom beach hack

  15. For heavy and obese severals or singles, a mattress that holds their structure with the bulk with comfortable fillings
    is a hard search.

    My homepage california king sized bed – Ricky,

  16. That is, when searching for a memory foam bed mattress
    online, you should customize points to you separately – size sensible, I
    indicate.

    Here is my page: memory foam for sale – Tonia,

  17. To get a secure and reliable connection, with a new
    IP address, virtual private networks (VPN) are your
    best option. So if you want one of the best gaming laptops you better be ready to have your wallet take a beating.

    It is important to introduce character building activities and to censor games, ensuring suitability.

  18. ‘The future possibilities for growth and success are good for
    this joint venture, you have got a dynamic, well integrated young company being partnered with a
    truly global tech giant and both trying to break into
    a under exploited and large market. The most visible change in the future are things called ROM’s, or “Relationship Organizational Managers,” which
    are personal robots that help with everyday tasks from public
    transportation, to cleaning houses, or health care.
    Though everything that we do in extreme carries its own sets of disadvantages
    but with proper care and guidance parents call actually use the online gaming as a tool of
    learning for their children.

  19. Psychics can help you take a glance into your future. In this way you honor yourself and you honor the psychic by giving them the time necessary to tune into your
    situation and effectively answer your questions. This will also help you to be
    more prepared for the situation that you are getting into.

  20. Spot on with this write-up, I seriously think this amazing site
    needs a lot more attention. I’ll probably be back again to
    read more, thanks for the information!

  21. Hi there! I know this is kinda off topic but I’d figured I’d ask.
    Would you be interested in exchanging links or maybe guest writing
    a blog article or vice-versa? My website discusses a lot of
    the same subjects as yours and I believe we could greatly benefit from each other.
    If you are interested feel free to shoot me an email. I look forward to hearing from you!
    Awesome blog by the way!

  22. The book discussed in this short article is The 33 Techniques of War
    by Robert Greene (Penguin Books, 2007, ISBN 978-0-14-311278-5, trade ppb, $18.00).

    Feel free to surf to my homepage … class

  23. Its such as you learn my mind! You seem to grasp so much approximately this, like you wrote the e book in it or something.
    I think that you simply can do with some % to force the message house a little bit, but other than that, this is great blog.
    A great read. I’ll certainly be back.

  24. The backend part of your company supports these profit centers.
    , it is best to go for affiliate marketing being
    an initial step into the world of generating impartial
    income from home. Efficiency: Many carriers provide multiple
    receive emails, so your fax messages are automatically delivered to whomever you intend.

  25. Hеllo! Ƭhіѕ іѕ ҝind of оff topic Ьut I ne&#6513d
    ѕome &#1211elp from ann established blog.
    Ӏѕ іt difficult tto ѕ&#6513t &#6489р yοur &#1086wn blog?
    &#8544’m noot ѵery techincal buut Ӏ can figure
    tings out pretty quick. ӏ’m thinking about creating my oown Ьut
    ӏ’m not ѕure ԝhere to
    begin. Dߋ ʏou &#1211ave ɑny tips or suggestions?

    &#5076ith thanks

    Feel frwe too visit mү webpage … Berita Basket indonesia

  26. With havin so much content and articles do you ever run into any issues of
    plagorism or copyright infringement? My site has a lot of unique content
    I’ve either written myself or outsourced but it looks like a
    lot of it is popping it up all over the internet without my agreement.

    Do you know any techniques to help reduce content from being stolen? I’d really appreciate it.

  27. Chicago life trainers take a variety of different approaches to assisting you accomplish the very best that is within you.

    Stop by my web site … nutrition coach jobs london (Chanda)

  28. I currently have actually limited spaces available for once a week training sessions at
    really sensible prices.

    My weblog wellness coach certification california (Ida)

  29. I am no longer positive the place you’re getting your info, however great
    topic. I must spend some time studying much more or understanding more.

    Thank you for excellent info I was on the lookout for this information for my mission.

  30. Part 2 ‘ Essential Features For A Successful Site – Saturday,
    February 5th ‘ 1:45pm ‘ 4pm. Dedicated servers as well as Colocation Servers have individual pros and cons.
    Now you must think that why it is different from shared hosting and Dedicated hosting.

  31. When it comes to a blockbuster hit, you will find that the movie
    reviews provide high ratings for that particular movie.

    Dropped frames occur when there is a start and stop on the tape where
    there are frames that are not recorded on, and then disrupt the flow of video capture when the footage is being digitized.

    In 2006 the movie Blood Diamond premiered in theaters and opened up a discussion about why
    our society needs diamonds so much, where we get them from and what the consequences
    are.

  32. We all have our own personal favourite smartphone
    manufacturers really, some of us prefer Apple, some Samsung,
    but what is your smartphone saying about you as a person.
    ‘ So by reducing the amount of time spent on the cell phone, one can reduce the exposure to it.
    The world of gadgets is very huge and people always like
    to use the hi-tech and advanced electronic items in their day to day
    life whether it is mobile or laptop.

Comments are closed.