473,699 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 16786
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*********@di scussions.micro soft.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.co m>
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.co m> wrote:
Mark R. Dawson <Ma*********@di scussions.micro soft.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.co m> wrote:
Mark R. Dawson <Ma*********@di scussions.micro soft.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
2559
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 character after word-ending dot, this is why i use the function: function getCorrect($txt) { $txt=str_replace(",",", ",$txt); $txt=str_replace(".",". ",$txt);
6
16172
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
10690
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 fields: BuildName and RoadName. Both have the following properties: size 50, not indexed, not required, allowed zero length. Some records have BuildName, RoadName as null, some have content. No content is 50 chr long. When i run a Len(BuildName)...
11
10592
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
7218
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 spaces, those are the spaces between the words. But most of what is in the fields has been cut-n-pasted from online forms, and the results can be VERY spread out. I could probably save 80% of the space if I could get rid of the extra white space....
4
3186
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 (onlySpaceRegexp.test(val) || val == "") {
8
17510
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 space. What would be the most efficient way to do this? I am using SQL2K. I was thinking a function since I know of no single Transact-SQL command that can accomplish this task.
0
1184
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 giving error as Space() not defined . Then i made my customized space function and registered VBES6.DLL FILE ALSO. now it's giving error on format function just like in case of Space(). Now what should i do to resolve this issue. Can anybody help...
3
1505
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 when I write this data to a textfile, it's formatted the way I want it to be. But when I display it with the print preview dialog, the format is wrong. I was able to trace the problem to either the Space function or the font. When writing to a file,...
3
2497
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 getListOfAllDatabaseTables.php. The file is included when the function needs to be called. The function is called when users are adding in new information. Most of the time, if a user fills in a form to (say for instance) create a new weblog post, the user would hit...
0
8706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9055
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8944
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6550
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4391
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4638
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3075
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2364
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2016
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.