# How create unambiguous random numer [Answered]RSS

## 6 replies

Last post Feb 04, 2012 01:47 PM by srinanthuram

Member

10 Points

180 Posts

### How create unambiguous random numer

Feb 02, 2012 07:57 PM|clembo67|LINK

I need to create a unambiguous random code.

max lenght is 24 char.

How I can do it? I thought to guid but is too long.

Any ideas?

Member

200 Points

79 Posts

### Re: How create unambiguous random numer

Feb 03, 2012 12:03 AM|fred_b|LINK

please see this

http://www.obviex.com/Samples/Password.aspx

Member

10 Points

180 Posts

### Re: How create unambiguous random numer

Feb 03, 2012 05:28 AM|clembo67|LINK

My problem is that this number/code must to be unique like guid but more short.

Participant

1090 Points

508 Posts

### Re: How create unambiguous random numer

Feb 03, 2012 05:38 AM|kirupa.v|LINK

Try these

http://snipplr.com/view/3584/

http://www.eggheadcafe.com/community/csharp/2/10049623/random-numbers.aspx

Contributor

4617 Points

1036 Posts

### Re: How create unambiguous random numer

Feb 03, 2012 04:00 PM|Ramesh T|LINK

Hello Mate,

This post may help you

http://forums.asp.net/t/1764721.aspx/1?Generation+of+Unique+Integer+8+Digit+Random+Number+

Cheers.

Member

110 Points

70 Posts

### Re: How create unambiguous random numer

Feb 03, 2012 10:34 PM|tom22|LINK

try this

```private readonly Random _rng = new Random();
private const string _chars = "abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789";

private string RandomString(int size)
{
char[] buffer = new char[size];

for (int i = 0; i < size; i++)
{
buffer[i] = _chars[_rng.Next(_chars.Length)];
}
return new string(buffer);
}```

Contributor

3935 Points

1422 Posts

### Re: How create unambiguous random numer

Feb 04, 2012 01:47 PM|srinanthuram|LINK