Solved

Random number with an existing list using C Sharp

Posted on 2011-03-17
3
283 Views
Last Modified: 2012-05-11
I need C# code that will select a random customer account number.  The problem is I do not want the customer number selected if they are not active.  How do I choose a random number from a generated list?

0
Comment
Question by:BobRosas
3 Comments
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 50 total points
Comment Utility
Psedocode:
do
   random = new random between 0 and upper bound (index) of list
while list[random].Active != True

acct = list[random]

Open in new window

0
 
LVL 9

Assisted Solution

by:Misbah
Misbah earned 50 total points
Comment Utility
you need to write code similar to the one below:
Customer[] list = ....
Random r = new Random(list.Length-1);
Customer random = list[r.next];
while(!random.IsActive)
{
random = list[r.next];

}

Open in new window

0
 

Author Comment

by:BobRosas
Comment Utility
I'm having other issues so I won't be able to test this yet.  I've doubled points and awarded you both for your help.  I'll post related questions if needed.
Thanks so much!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
the name DateAdd does not exist in this context 2 31
optimize  c# code 7 48
fomat Json objects 6 12
Achieve json result 2 20
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now