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

x
?
Solved

How to add characters or strings to a string?

Posted on 2004-08-23
2
Medium Priority
?
196 Views
Last Modified: 2010-04-15
string text = "";
string add = "badger";

I want some function so that 'text' would equal to "badgerbadgerbadgerbadger..." and so on. The 'add' would be inserted into 'text' a specified amount of times.

I have tried the 'Insert()' function, but it does not seem to work. Thanks!

0
Comment
Question by:krupini
[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
2 Comments
 
LVL 22

Accepted Solution

by:
cookre earned 320 total points
ID: 11877409
for (i=0; i<n; i++) text=text+add;
0
 
LVL 3

Expert Comment

by:gillgates
ID: 11877435
string add(string stringtoadd, int numberofadds)
{
    string temp = "";

    for(int i = 0; i<numberofadds; i++)
    {
          temp += stringtoadd;
    }
   
    return temp;
}        
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
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