Solved

How to add characters or strings to a string?

Posted on 2004-08-23
2
190 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
2 Comments
 
LVL 22

Accepted Solution

by:
cookre earned 80 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now