473,325 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

How space function in C#

ad
Is there fucntion in C#, which will return a string consist of a given
number of space, like

Space(5)-> " ";

Nov 17 '05 #1
5 16764
ad wrote:
Is there fucntion in C#, which will return a string consist of a given
number of space, like

Space(5)-> " ";


new String(' ', 5)

--

www.midnightbeach.com
Nov 17 '05 #2
string strPadded = "".PadRight(5);

"ad" wrote:
Is there fucntion in C#, which will return a string consist of a given
number of space, like

Space(5)-> " ";

Nov 17 '05 #3
Mark R. Dawson <Ma*********@discussions.microsoft.com> wrote:
string strPadded = "".PadRight(5);


That will work, but I personally far prefer Jon Shemitz's solution -
it's more readable, and it's very obvious how to go from that to a
string of 5 tabs, say.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4
On Sun, 21 Aug 2005 08:18:58 +0100, Jon Skeet [C# MVP]
<sk***@pobox.com> wrote:
Mark R. Dawson <Ma*********@discussions.microsoft.com> wrote:
string strPadded = "".PadRight(5);


That will work, but I personally far prefer Jon Shemitz's solution -
it's more readable, and it's very obvious how to go from that to a
string of 5 tabs, say.


Well, you still can do the same with padding:

"".PadRight( 5, '\t' );

But as of preference, I still agree with you :))
Nov 17 '05 #5
On Sun, 21 Aug 2005 08:18:58 +0100, Jon Skeet [C# MVP]
<sk***@pobox.com> wrote:
Mark R. Dawson <Ma*********@discussions.microsoft.com> wrote:
string strPadded = "".PadRight(5);


That will work, but I personally far prefer Jon Shemitz's solution -
it's more readable, and it's very obvious how to go from that to a
string of 5 tabs, say.


Well, you still can do the same with padding:

"".PadRight( 5, '\t' );

But as of preference, I still agree with you :))
Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Patryk Konieczka | last post by:
Hello Here's the thing I have a database edited by some company workers editing descriptions of books in the sotre , unfortunately these workers do not have the habit of inserting a space...
6
by: Grumble | last post by:
Hello all, I want to read lines from a text file, where each line has the following syntax: token1:token2:token3 There could be white space between tokens and ':'
3
by: Andy B | last post by:
I've tried using Trim or RTrim to strip trailing space characters from my data. When I check on the transformed data space characters are still there. We have an address table containing two...
11
by: PC Datasheet | last post by:
How do I get the Len function to count a space at the end of a string? For example, if I enter AB(space), how do I get Len to return 3 instead of 2? Thanks, Steve
12
by: JA | last post by:
Is there a way to remove all the white space in the fields? I have been using Find-and-replace - looking for 2 or 3 or 4 or 10 spaces and replacing them with none. I don't want to replace single...
4
by: whisher | last post by:
Hi. I'm taking my first steps on regex I set up this simple function to check if a form field is empty or with only space. var onlySpaceRegexp = /^\s*$/; function isEmpty(val) { if...
8
by: Joe Cool | last post by:
I need to map several columns of data from one database to another where the data contains multiple spaces (once occurance of a variable number or spaces) that I need to replace with a single...
0
by: ajay pratap singh111 | last post by:
I have used space() and format() function in one of my project on excel vba. The project was running on my system but when i made its setup file using innoSetup and gave it to my client then it's...
3
by: preethi303 | last post by:
Hi, I'm using VB 2005 and I have a problem formatting a string when I use the print preview dialog box. I'm using just the vbCrLf character and the Space function to correctly align my data and...
3
by: Lawrence Krubner | last post by:
This is one of the more bizarre things I've seen in a while. We've a function called getListOfAllDatabaseTables that does about what you'd expect. It lives in a file called...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.