Click here to Skip to main content
15,891,778 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello people,

i'm need adding a ' into my string in every position off my list<string>

C#
List<string> list = new new List<string>();
list.add("Name");
list.add("Surname");

string myString = "(" + string.Join(", ", permissionsRequired.ToArray()) + ")";


this code return (Name, Surname), but i want return ('Name', 'Surname')

anybody can help me?

thanks
Posted

Try:
C#
string myString = "('" + string.Join("', '", permissionsRequired) + "')";

(You don't need the ToArray - String.Join has an IEnumerable override: http://msdn.microsoft.com/en-us/library/dd783876(v=vs.110).aspx[^])
 
Share this answer
 
Comments
EduChapow 24-Jan-14 14:45pm    
thankssss
OriginalGriff 24-Jan-14 14:52pm    
You're welcome!
Rahul VB 27-Jan-14 14:39pm    
Guess who upvoted your answer?
OriginalGriff 27-Jan-14 14:45pm    
Um.

Was it...the Pope? :OMG:
Rahul VB 27-Jan-14 14:50pm    
hey hey, it was me. hahah :). OG tell me one thing how are you always available? i mean what ever may be the question you are always on it. I read your answer where some one had mistakenly renamed the file: .txt.txt remember? How do you do that? Do you even read minds? hahah:) Well : i suggest code project to Start the Man of the moment awards too.
Using String.Format ex :- http://www.dotnetperls.com/string-format[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900