what's the best way of getting unique numbers when requested other than
creating GUIDs? Right now this is what I am doing but I am not very happy
with it.
Random rnd=new Random((int)System.DateTime.Now.Ticks);
int unique=rnd.Next();
TIA
--
========
Regards
Vai
======== 13 1216
Hi Vai
What are these numbers for? Are they for records in a database? What is
wrong with a Guid?
Gary
"Vai2000" <va*@onebox.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... what's the best way of getting unique numbers when requested other than creating GUIDs? Right now this is what I am doing but I am not very happy with it.
Random rnd=new Random((int)System.DateTime.Now.Ticks); int unique=rnd.Next();
TIA
-- ======== Regards Vai ========
"Vai2000" <va*@onebox.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... what's the best way of getting unique numbers when requested other than creating GUIDs? Right now this is what I am doing but I am not very happy with it.
Random rnd=new Random((int)System.DateTime.Now.Ticks); int unique=rnd.Next();
TIA
-- ======== Regards Vai ========
Hi,
A random number is NOT unique! It is unpredictable (that's what "random"
means :-) ) but it is possible to get duplicate values.
Hans Kesting
Unfortunately I need this value for creating unique numerical ID (Its part
of a naming convention) - I don't have access to DB!!
Thanks
"Gary van der Merwe" <ga*****@hotmail.com> wrote in message
news:ub**************@TK2MSFTNGP12.phx.gbl... Hi Vai
What are these numbers for? Are they for records in a database? What is wrong with a Guid?
Gary
"Vai2000" <va*@onebox.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... what's the best way of getting unique numbers when requested other than creating GUIDs? Right now this is what I am doing but I am not very
happy with it.
Random rnd=new Random((int)System.DateTime.Now.Ticks); int unique=rnd.Next();
TIA
-- ======== Regards Vai ========
Do you have any way of determining the names allready created?
"Vai2000" <no****@microsoft.com> wrote in message
news:ul**************@TK2MSFTNGP10.phx.gbl... Unfortunately I need this value for creating unique numerical ID (Its part of a naming convention) - I don't have access to DB!!
Thanks
"Gary van der Merwe" <ga*****@hotmail.com> wrote in message news:ub**************@TK2MSFTNGP12.phx.gbl... Hi Vai
What are these numbers for? Are they for records in a database? What is wrong with a Guid?
Gary
"Vai2000" <va*@onebox.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... what's the best way of getting unique numbers when requested other
than creating GUIDs? Right now this is what I am doing but I am not very happy with it.
Random rnd=new Random((int)System.DateTime.Now.Ticks); int unique=rnd.Next();
TIA
-- ======== Regards Vai ========
"Vai2000" <va*@onebox.com> wrote in
news:#M**************@TK2MSFTNGP10.phx.gbl: what's the best way of getting unique numbers when requested other than creating GUIDs?
Use a linear series: 1, 2, 3, etc...
Chris.
-------------
C.R. Timmons Consulting, Inc. http://www.crtimmonsinc.com/
No
"Gary van der Merwe" <ga*****@hotmail.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl... Do you have any way of determining the names allready created? "Vai2000" <no****@microsoft.com> wrote in message news:ul**************@TK2MSFTNGP10.phx.gbl... Unfortunately I need this value for creating unique numerical ID (Its
part of a naming convention) - I don't have access to DB!!
Thanks
"Gary van der Merwe" <ga*****@hotmail.com> wrote in message news:ub**************@TK2MSFTNGP12.phx.gbl... Hi Vai
What are these numbers for? Are they for records in a database? What
is wrong with a Guid?
Gary
"Vai2000" <va*@onebox.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... > what's the best way of getting unique numbers when requested other than > creating GUIDs? Right now this is what I am doing but I am not very
happy > with it. > > > Random rnd=new Random((int)System.DateTime.Now.Ticks); > int unique=rnd.Next(); > > TIA > > -- > ======== > Regards > Vai > ======== > >
Could you please elaborate a little more? basically I don't have any
knowledge of my last number, so how can I ensure a linear number?
Thanks
PS: Ways I can think would be registry etc to maintain a starting seed and
then increment it everytime.
"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message
news:Xn**********************************@207.46.2 48.16... "Vai2000" <va*@onebox.com> wrote in news:#M**************@TK2MSFTNGP10.phx.gbl:
what's the best way of getting unique numbers when requested other than creating GUIDs?
Use a linear series: 1, 2, 3, etc...
Chris. ------------- C.R. Timmons Consulting, Inc. http://www.crtimmonsinc.com/
"Vai2000" <no****@microsoft.com> wrote in
news:ue**************@TK2MSFTNGP09.phx.gbl: Could you please elaborate a little more? basically I don't have any knowledge of my last number, so how can I ensure a linear number?
Thanks PS: Ways I can think would be registry etc to maintain a starting seed and then increment it everytime.
If you can somehow save (or find out) the value of the last number
used in the series, then it should be simple:
number is requested
get value of most recently used number (from a data store)
increment number
store new number value in the data store
return number
Multi-user and multi-threaded access should be planned for. The
above pseudo-code should be be "locked" somehow so only one
thread/user can access it at a time. With threads, the "lock"
statement can be used. With databases, the code can be wrapped in a
transaction, or the isolation level can be set to serial access.
Chris.
-------------
C.R. Timmons Consulting, Inc. http://www.crtimmonsinc.com/
You still haven't answered Garys original question. Whats wrong with a Guid
? This is the most reliable and easy way of generating a unique (to all
practical purposes) number on any computer without a complex error prone
tracking system.
Cheers
Doug Forster
"Vai2000" <no****@microsoft.com> wrote in message
news:ue**************@TK2MSFTNGP09.phx.gbl... Could you please elaborate a little more? basically I don't have any knowledge of my last number, so how can I ensure a linear number?
Thanks PS: Ways I can think would be registry etc to maintain a starting seed and then increment it everytime.
"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message news:Xn**********************************@207.46.2 48.16... "Vai2000" <va*@onebox.com> wrote in news:#M**************@TK2MSFTNGP10.phx.gbl:
what's the best way of getting unique numbers when requested other than creating GUIDs?
Use a linear series: 1, 2, 3, etc...
Chris. ------------- C.R. Timmons Consulting, Inc. http://www.crtimmonsinc.com/
Well I need a number as to a GUID which is a combination of number and
alphabets!
TIA
"Doug Forster" <doug_ZAPTHIS_AT_TONIQ_ZAPTHIS_co.nz> wrote in message
news:uw**************@TK2MSFTNGP12.phx.gbl... You still haven't answered Garys original question. Whats wrong with a
Guid ? This is the most reliable and easy way of generating a unique (to all practical purposes) number on any computer without a complex error prone tracking system.
Cheers
Doug Forster
"Vai2000" <no****@microsoft.com> wrote in message news:ue**************@TK2MSFTNGP09.phx.gbl... Could you please elaborate a little more? basically I don't have any knowledge of my last number, so how can I ensure a linear number?
Thanks PS: Ways I can think would be registry etc to maintain a starting seed
and then increment it everytime.
"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in
message news:Xn**********************************@207.46.2 48.16... "Vai2000" <va*@onebox.com> wrote in news:#M**************@TK2MSFTNGP10.phx.gbl:
> what's the best way of getting unique numbers when requested > other than creating GUIDs?
Use a linear series: 1, 2, 3, etc...
Chris. ------------- C.R. Timmons Consulting, Inc. http://www.crtimmonsinc.com/
No a Guid is really a 16 byte number. You are thinking of the common hex
representation of a Guid. Use ToByteArray() and then you can represent it
however you like. Perhaps you could even 'condense' it at the risk of
reducing uniqueness.
Cheers
Doug Forster
"Vai2000" <va*@onebox.com> wrote in message
news:u7**************@TK2MSFTNGP12.phx.gbl... Well I need a number as to a GUID which is a combination of number and alphabets!
TIA
"Doug Forster" <doug_ZAPTHIS_AT_TONIQ_ZAPTHIS_co.nz> wrote in message news:uw**************@TK2MSFTNGP12.phx.gbl... You still haven't answered Garys original question. Whats wrong with a Guid ? This is the most reliable and easy way of generating a unique (to all practical purposes) number on any computer without a complex error prone tracking system.
Cheers
Doug Forster
"Vai2000" <no****@microsoft.com> wrote in message news:ue**************@TK2MSFTNGP09.phx.gbl... Could you please elaborate a little more? basically I don't have any knowledge of my last number, so how can I ensure a linear number?
Thanks PS: Ways I can think would be registry etc to maintain a starting seed and then increment it everytime.
"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message news:Xn**********************************@207.46.2 48.16... > "Vai2000" <va*@onebox.com> wrote in > news:#M**************@TK2MSFTNGP10.phx.gbl: > > > what's the best way of getting unique numbers when requested > > other than creating GUIDs? > > Use a linear series: 1, 2, 3, etc... > > > Chris. > ------------- > C.R. Timmons Consulting, Inc. > http://www.crtimmonsinc.com/
Great!!
"Doug Forster" <doug_ZAPTHIS_AT_TONIQ_ZAPTHIS_co.nz> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... No a Guid is really a 16 byte number. You are thinking of the common hex representation of a Guid. Use ToByteArray() and then you can represent it however you like. Perhaps you could even 'condense' it at the risk of reducing uniqueness.
Cheers
Doug Forster
"Vai2000" <va*@onebox.com> wrote in message news:u7**************@TK2MSFTNGP12.phx.gbl... Well I need a number as to a GUID which is a combination of number and alphabets!
TIA
"Doug Forster" <doug_ZAPTHIS_AT_TONIQ_ZAPTHIS_co.nz> wrote in message news:uw**************@TK2MSFTNGP12.phx.gbl... You still haven't answered Garys original question. Whats wrong with a Guid ? This is the most reliable and easy way of generating a unique (to
all practical purposes) number on any computer without a complex error
prone tracking system.
Cheers
Doug Forster
"Vai2000" <no****@microsoft.com> wrote in message news:ue**************@TK2MSFTNGP09.phx.gbl... > Could you please elaborate a little more? basically I don't have any > knowledge of my last number, so how can I ensure a linear number? > > Thanks > PS: Ways I can think would be registry etc to maintain a starting
seed and > then increment it everytime. > > "Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message > news:Xn**********************************@207.46.2 48.16... > > "Vai2000" <va*@onebox.com> wrote in > > news:#M**************@TK2MSFTNGP10.phx.gbl: > > > > > what's the best way of getting unique numbers when requested > > > other than creating GUIDs? > > > > Use a linear series: 1, 2, 3, etc... > > > > > > Chris. > > ------------- > > C.R. Timmons Consulting, Inc. > > http://www.crtimmonsinc.com/ > >
You can also use a SecureRandom to generate better random numbers. Decide
how often you are willing to have numbers collide, on average, and take
enough bits to ensure this.
If you aren't willing to have any collisions ever, you need to add a check
for uniqueness.
"Doug Forster" <doug_ZAPTHIS_AT_TONIQ_ZAPTHIS_co.nz> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... No a Guid is really a 16 byte number. You are thinking of the common hex representation of a Guid. Use ToByteArray() and then you can represent it however you like. Perhaps you could even 'condense' it at the risk of reducing uniqueness.
Cheers
Doug Forster
"Vai2000" <va*@onebox.com> wrote in message news:u7**************@TK2MSFTNGP12.phx.gbl... Well I need a number as to a GUID which is a combination of number and alphabets!
TIA
"Doug Forster" <doug_ZAPTHIS_AT_TONIQ_ZAPTHIS_co.nz> wrote in message news:uw**************@TK2MSFTNGP12.phx.gbl... You still haven't answered Garys original question. Whats wrong with a Guid ? This is the most reliable and easy way of generating a unique (to
all practical purposes) number on any computer without a complex error
prone tracking system.
Cheers
Doug Forster
"Vai2000" <no****@microsoft.com> wrote in message news:ue**************@TK2MSFTNGP09.phx.gbl... > Could you please elaborate a little more? basically I don't have any > knowledge of my last number, so how can I ensure a linear number? > > Thanks > PS: Ways I can think would be registry etc to maintain a starting
seed and > then increment it everytime. > > "Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message > news:Xn**********************************@207.46.2 48.16... > > "Vai2000" <va*@onebox.com> wrote in > > news:#M**************@TK2MSFTNGP10.phx.gbl: > > > > > what's the best way of getting unique numbers when requested > > > other than creating GUIDs? > > > > Use a linear series: 1, 2, 3, etc... > > > > > > Chris. > > ------------- > > C.R. Timmons Consulting, Inc. > > http://www.crtimmonsinc.com/ > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: freddy |
last post by:
how can I display a set of numbers like this:
1 2 3 4 5 6 ...
instead of this
1
2
3
4
5
....
|
by: Eduardo Bezerra |
last post by:
Hi,
I'm looking for an efficient way to create the oposite of a
list of numbers.
For example, suppose I have this list of numbers:
100
200
300
|
by: StenKoll |
last post by:
Help needed in order to create a register of stocks in a company. In
accordance with local laws I need to give each individual share a
number. I have accomplished this by establishing three tables...
|
by: Arun Bhalla |
last post by:
Hi,
I'm developing an Explorer bar using VS.NET 2003 (C#) on Windows XP. For
some time, I've noticed that I don't have filenames and line numbers
appearing in my exceptions' stack traces. On...
|
by: Leon |
last post by:
I have six textbox controls on my webform that allows the user to enter any
numbers from 1 to 25 in any order. However, I would like to sort those
numbers from least to greatest before sending them...
|
by: Sri |
last post by:
How do you add an n-bit number in C?
Regards,
Sri
|
by: bobalong |
last post by:
Hi
I'm have some problem understanding how JS numbers are represented
internally.
Take this code for an example of weirdness:
var biggest = Number.MAX_VALUE;
var smaller = Number.MAX_VALUE...
|
by: Dave Cox |
last post by:
of "int" in VB?
//b=1.2
b=int(b)
//b now equals 1
|
by: Peter Oliphant |
last post by:
I would like to be able to create a random number generator that produces
evenly distributed random numbers up to given number.
For example, I would like to pick a random number less than 100000,...
|
by: bilgekhan |
last post by:
What is the correct method for generating 2 independent random numbers?
They will be compared whether they are equal.
What about this method:
srand(time(0));
int r1 = rand();
srand(rand());...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |