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
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?