Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Formating of int to string in six digit

Posted on 2010-08-30
5
Medium Priority
?
552 Views
Last Modified: 2012-05-10
Hi,

I am working in web application C# using ASP.net3.5

I wanted to make any integer value to six digit

For example

- If int value is 120 then string value I need is 000120
- If int value is 35 then string value I need is 000035
- If int value is 3532 then string value I need is 003532

Can you please help me in formating this string


Many Thanks
0
Comment
Question by:tia_kamakshi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 664 total points
ID: 33559569
YourVariable.ToString("000000")
0
 
LVL 5

Accepted Solution

by:
makber earned 668 total points
ID: 33559589
int i = 555; // your integer variable
String.Format("{0:000000}", i);
0
 
LVL 27

Assisted Solution

by:Shaun Kline
Shaun Kline earned 668 total points
ID: 33559594
You can do this by using the PadRight string function:

int value = 120;
value.ToString().PadRight(6, "0");
0
 
LVL 4

Expert Comment

by:ricovox
ID: 33560730
any of the three above answers will work just fine. I suggest you choose the best answer for your particular application and divide the points.
0
 

Author Closing Comment

by:tia_kamakshi
ID: 33569731
Many Thanks for your support
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

604 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