?
Solved

How to add prefix to a string?

Posted on 2014-10-09
3
Medium Priority
?
535 Views
Last Modified: 2014-10-09
How to add prefix to a string in c#?

For example I have a strin '1234' and I would like to add page as prefix to the string.

For example:  page1234

How can I implement this in c#?

Thanks.
0
Comment
Question by:developer2012
[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
3 Comments
 
LVL 21

Accepted Solution

by:
Randy Poole earned 1500 total points
ID: 40370968
string mystring="1234";
mystring="page"+mystring;

Open in new window

0
 

Author Comment

by:developer2012
ID: 40370973
Is there anyway we can do it by Replace Method?
0
 
LVL 21

Assisted Solution

by:Randy Poole
Randy Poole earned 1500 total points
ID: 40370990
You really are not replacing anything. But you could add a place holder to your string.  Or you could use insert:
Using place holder:
string mystring="*1234";
string repvalue="page";
mystring=mystring.replace("*",repvalue);

Open in new window

Insert method
string mystring="1234";
string repvalue="page";
mystring=mystring.Insert(0,repvalue);

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

800 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