c#


How to convert List<string> into String of Comma Separated Quotes from List [duplicate]


This question already has an answer here:
convert multiline comma separated textbox values with single quotes
2 answers
I am trying to convert a list of strings into a comma separated with quotes variable,I can only join them as comma separated but can't put quotes around each of the entries in the list..can anyone provide guidance on how to fix it?
INPUT:
variants =
[
"CI_ABC1234.LA.0.1-03391-STD.INT-32",
"CI_ABC1234.LA.0.1-33103-STD.INT-32"
]
EXPECTED OUTPUT:
('CI_ABC1234.LA.0.1-03391-STD.INT-32','CI_ABC1234.LA.0.1-33103-STD.INT-32')
CODE:-
string variants_str = String.Join(",", variants);
LINQ's Select() extension method allows to convert each item in a collection:
string variants_str = String.Join(",", variants.Select(s => "'" + s + "'"));
Demo: https://dotnetfiddle.net/I37xr6

Related Links

Is it a good practice to cache exception instance in C#
Can i use “#Url.Action” in c# (Inside .aspx page)
WPF C# - Loading MySQL Query into DataGrid
Using two version of same nuget package
c# Component Executing Life Cycle
MVC5 Change Database and Entity Model Classes dynamically
Does ValideAntiForgeryToken prevent falsifying of POST parameters?
C# SilverLight User Control - Custom Panel not presented on the Form (XAML.CS file)
Skipping Read URL data of IP Camera in MS Access Which is not Active C#
Second-level property binding in wpf Datagrid DataGridTemplateColumn TextBlock
C# How do we use Object.GetHashCode() [duplicate]
The entity type ApplicationUser is not part of the model for the current context after swapping server from local to external
TextBox.Clear() or TextBox.Text = string.Empty
Get the value from a div using HtmlAgilityPack
What do you pass as DataGridViewCellFormattingEventArgs in the handler datagridView1_CellFormatting()?
Implementing two contact forms with validation controls in a single page in ASP.NET?

Categories

HOME
skype-for-business
kendo-ui-angular2
ide
service
spss
download
grid
ms-access-2010
docker-compose
collision-detection
google-my-business-api
urllib2
yui
swift3.1
lambda-calculus
multibinding
simd
windows-phone
draw2d
aws-devicefarm
project-structure
caldav
keystone
webgl-earth
cherrypy
v4l2
ithit-webdav-server
ppp
git-submodules
request-uri
osgi-bundle
ipython-parallel
edirectory
drawrect
exacttarget
http-proxy
ansible-inventory
area
motion
ngrok
paperclip
scrapinghub
amazon-fire-tv
synchronized
anonymous-function
serverless-architecture
google-chrome-storage
hierarchical-clustering
confluent
ear
sharpdevelop
ajv
selection-sort
zedgraph
wicketstuff
suitesparse
cardview
lightspeed
zsh-completion
alfred
jira-agile
disconnect
tinybox2
scriptengine
avaudiorecorder
web-optimization
ios8-share-extension
lytro
dpkt
grails-3.0.9
teamwork
stderr
chrome-mobile
fiware-health
caption
illegalargumentexception
novell
system.net
worklight-appcenter
msdropdown
cs193p
reactjs-native
pidgin
object-oriented-database
data-layers
objectdatasource
friendly-url
http-compression
mmo
biztalk-deployment
boost.build
esi
report-viewer2010
winrt-async
jquery-ui-map
maven-eclipse-plugin
moss2007-security
cinder
excellibrary
azure-appfabric
viewdata
chromebug
qprocess
script-tag
user-preferences

Resources

Encrypt Message