473,903 Members | 3,390 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how do you create string of repeating characters?

How do I create a string consisting of a specified character repeated a
specified number of times?

Something like
String.Fill('x' , 10) to create "xxxxxxxxxx "

The best I see would be some hack using PadLeft() or (probably better) some
method written from scratch.
Nov 15 '05 #1
2 41942
100
Hi Daniel,

String str = new String('x', 10);

This will do.

HTH
B\rgds
100

"Daniel Billingsley" <db**********@N O.durcon.SPAAMM .com> wrote in message
news:e8******** ******@TK2MSFTN GP12.phx.gbl...
How do I create a string consisting of a specified character repeated a
specified number of times?

Something like
String.Fill('x' , 10) to create "xxxxxxxxxx "

The best I see would be some hack using PadLeft() or (probably better) some method written from scratch.

Nov 15 '05 #2
DOH! Looked everywhere but there. Thanks.

"100" <10*@100.com> wrote in message
news:e%******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi Daniel,

String str = new String('x', 10);

This will do.

HTH
B\rgds
100

"Daniel Billingsley" <db**********@N O.durcon.SPAAMM .com> wrote in message
news:e8******** ******@TK2MSFTN GP12.phx.gbl...
How do I create a string consisting of a specified character repeated a
specified number of times?

Something like
String.Fill('x' , 10) to create "xxxxxxxxxx "

The best I see would be some hack using PadLeft() or (probably better)

some
method written from scratch.


Nov 15 '05 #3

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

Similar topics

4
1884
by: PD | last post by:
Hello, I am new to python, but i am quite curious about the following. suppose you had print '\378' which should not work because \377 is the max. then it displays two characters (an 8 and a heart in my case...). What else does'nt quite
3
1864
by: Cavello | last post by:
Hi, I'm curious as to how I can input a string of characters and then output it in sections, seperating these sections according to a particular value entered, for example a period. Say if I enter 'today.is.friday', I want the screen to output: today is friday How is this done?
4
36764
by: Merlin | last post by:
Hi there, I would like to check if a string is a valid zip code via Javascript. Length and existents are already checked. How can I find out if the string contains characters other than numbers? Example: 834F7 schould be false since it countains an F character
5
5170
by: Hels Bells | last post by:
Hi, I'm looking to do some manipulation on a string containing html code in asp which will involve me either using some regular expressions or just plain old simple replace functionality. The text that I want to use will have double quotes in it (as it's xhtml code) so I can't set it as a string value and is actually brought into the page from a content managed element (the details of which I don't think I'll need to go into but...
11
2383
by: mauiboy | last post by:
programming newbie. I'm work on a program that post characters into foreground application. everything is working nicely except for repeating characters. I thought using a task timer was the way to go but it seems that as the JVM cleans its garbage the time tries to catchup therefore posting more cycles in it preset duty cycle. any hints on using java to control repeating characters or tasks?
6
4227
by: Phil Barber | last post by:
I am using Regex to validate a file name. I have everything I need except I would like the dot(.) in the filename only to appear once. My question is it possible to allow one instance of character but not two or more? example myfile.doc = good My.file.doc = not good if you could give an example of the expression pattern that would most helpful. thanks phil
7
1758
by: ldphill | last post by:
I am very new to C#. I need help with creating the string, concatenating the string and displaying the information on separate lines. Here is what I am doing: 1. Write this Application in C# 2. It is a Console Application. 3. Use “MileStones” as a Namespace. 4. You shall have two files: a. TestApp.cs b. Person.cs
0
2032
by: rehman | last post by:
Hi, I added reference to COM Component Microsoft ADO Ext. 2.8 for DDL and Security which added a wrapper DLL Interop.ADOX.dll in project references in a web application to create MS Access database dynamically. It all works fine in development environment ( VS 2008 + Win 2003 Server. + 32-bit Machine) The aformentioned web application is deployed on IIS 7 + Win server 2008 + 64 - bit machine, where it throws following exception...
7
3694
by: nigelmercier | last post by:
I want to create a bar-graph display using a string. The string needs to be 14 characters long, filled from the left with either a '#' character or a ' ' depending on the value of a variable, level. Each character represents 1/14 of the total (this is my display width), so as level rises from 0 to 14, there will be more # characters on the left, and fewer spaces, viz: If level < 1, the string should be: " " If level == 1,...
0
9999
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
9847
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11283
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10986
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,...
0
10501
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5894
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
6093
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3324
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.