Buy Questpond's video subscriptions on
huge discount
.
Online: 3895
Home
Articles
Interviews
Forums
For Beginners
Popular Questions
ITIL Career Advice
PMP Career Advice
Career Advices
Codes
Videos
ASP.NET
ASP.NET MVC
Android Intel XDK
Sql Server
AngularJS
Bootstrap
Backbone.JS
MongoDB
LESS (CSS)
jQuery
WPF
WWF
SSIS
LightSwitch
Tutorials
News
ASP.NET MVC
|
Be Interview Ready
|
Top Performers
|
DNF MVP
|
Top Posts
|
Winners
|
Subscribe
|
Catalogs
Welcome Guest !
Register
Login
Home
>
Forums
>
C#
>
Loading ...
code for generating numbers
Posted by
Amritha444
under
C#
on 2/26/2011 |
Points: 10
| Views : 1985 | Status :
[Member]
| Replies : 7
Write New Post
|
Search Forums
|
Resolved Posts
|
Un Answered Posts
|
Forums Home
Hi all
I want to generate auto number corresponding to primary keys
like
if pk is 1 the no will be 000001
if pk is 10 :000010
if 100: 000100
the total digits in a number should be same..how to code for it in c#?
Thanks in advance
Reply
|
Reply with Attachment
Alert Moderator
Responses
Posted by:
Naimishforu
on: 2/26/2011
[Member]
[MVP]
Bronze
|
Points: 25
0
You want C# logic for the same???
Amritha444
, if this helps please
login
to
Mark As Answer
. |
Alert Moderator
Posted by:
Amritha444
on: 2/26/2011
[Member]
Starter
|
Points: 25
0
yes
I f have any existing code .please paste here
Amritha444
, if this helps please
login
to
Mark As Answer
. |
Alert Moderator
Posted by:
Madhu.b.rokkam
on: 2/26/2011
[Member]
[MVP]
Bronze
|
Points: 25
0
int num = 10;
Console.WriteLine(Convert.ToString(num).PadLeft(6,'0'));
Try this it works
Thanks and Regards
Madhu
Amritha444
, if this helps please
login
to
Mark As Answer
. |
Alert Moderator
Posted by:
Naimishforu
on: 2/26/2011
[Member]
[MVP]
Bronze
|
Points: 25
0
Haha...I was thinking similar solution...but this one looks great!!
Amritha444
, if this helps please
login
to
Mark As Answer
. |
Alert Moderator
Posted by:
Madhu.b.rokkam
on: 2/26/2011
[Member]
[MVP]
Bronze
|
Points: 25
0
I read your mind Naimish ....
Thanks and Regards
Madhu
Amritha444
, if this helps please
login
to
Mark As Answer
. |
Alert Moderator
Posted by:
Naimishforu
on: 2/26/2011
[Member]
[MVP]
Bronze
|
Points: 25
0
hehehehe!!!!
Amritha444
, if this helps please
login
to
Mark As Answer
. |
Alert Moderator
Posted by:
Madhu.b.rokkam
on: 2/26/2011
[Member]
[MVP]
Bronze
|
Points: 25
0
One more way too you can use that is as below
int yourNumber= 100;
Console.WriteLine(yourNumber.ToString("D6", CultureInfo.InvariantCulture));
Thanks and Regards
Madhu
Amritha444
, if this helps please
login
to
Mark As Answer
. |
Alert Moderator
Login to post response
Latest Posts
How to get the exact property name while getting error
(0)
PDB file is not showing Line Number in dot net application hosted on server
(0)
Both Strings morethan 5 letters in length end of the words one vowel and one consonent is different
(0)
how to check Any adjacent letters transposed between two strings(ex: JOHN, JHON)
(1)
can't receive data after success login ?
(1)
Implement Multi-Tenant in Azure Logic Apps
(0)
Why ASP.Net Core 7.0 Web API showing as Connection refused?
(0)
Iterating over columns of dataframe and print as rows in Python Django
(0)
More ...