score:1
Accepted answer
You can use String.Trim method like this:-
first.SetField("SameReferences", string.Format("{0},{1}", duplicate,
first.Field<string>("SameReferences")).Trim(','));
It will remove all the trailing comma.
score:0
Try this:
if (first.Field<string>("SameReferences") != null)
{
string duplicate = first.Field<int>("SortOrder").ToString();
string sameReference = first.Field<string>("SameReferences");
if (String.IsNullOrEmpty(sameReference))
first.SetField("SameReferences", duplicate);
else
first.SetField("SameReferences", string.Format("{0},{1}", duplicate, sameReference));
}
Source: stackoverflow.com
Related Query
- Eliminate comma(,) from a column of a Data Table using LINQ
- How to reinsert data from one table onto itself using LINQ in code migration?
- want to get data from specific column of azure mobile service table using linq
- How to check comma separated values stored in data base column having the given value using linq in c#
- Using Linq to extract data from a Table
- remove rows from data table using LINQ
- Get data from a table after joining based on null value of joined table using LINQ
- Display (flat) row of data from a table in a specific format using MVC / LINQ
- Using Linq to pull from IEnumerable<XElement> and store in data table
- Using LINQ to generate Highchart column table data
- Get All Row Elements of Data Table From Column LINQ c#
- Get columns values in data table using linq from Entity Framework
- Access data from indirect child table using LInq
- Filter data using LINQ from two table
- Retrieving data from the table using LINQ to SQL
- LINQ: join multiple Table Column using Linq and find aggregated sum from child table values
- Select a table column from IEnumerable using Linq
- How to Get data in repeater from multiple table using like linq query
- selecting a column values from a Table using LINQ (Entity Framework)
- Getting data from foreign key table using LINQ
- How to get a column value from data table with Linq
- Get values from a column having comma separated values using Linq
- Get data with Sum from a table after multiple joining using LINQ
- How do I add data to column from another table in a SQL Server using .NET Framework?
- c# Linq or code to extract groups from a single list of source data
- Select data from tow table using LINQ in Asp Core razor pages
- how to fetch data from database using linq query for relationship 1:N and N:N (between 3 entity) in asp.net mvc EF code first?
- How can we get list of two column say firstname and lastname from customer table in mvc using linq query
- Retrieve data from child table using parent table LINQ query
- Get data from two tables using LINQ without any column key
More Query from same tag
- VB LINQ datatable - latest dates in the ascending order
- Selecting subset of innermost Descendants using LINQ to XML
- How to select rows from DataTable based on Index / Row Number?
- Group by on multiple columns and trace values which are not distinct
- RowNumber using Linq
- C# Linq GroupBy and Count field
- Unable to fetch data from Azure Cosmos DB
- LINQ Extension method .SelectMany() written in another form
- Retrieve nested list from XDocument with LINQ
- linq join code doesn't work
- How to project properties depending on conditions with LINQ and Entity Framework?
- LINQ and EF6: The context cannot be used while the model is being created
- returning single result using LINQ
- Linq how to move all values of two columns to another table
- Modify List<T> using Linq to Average rows with matching designator
- Referencing DataRows by column name in a LINQ query, then filter via mapping with another dataset
- Linq InnerJoin 4 tables
- LINQ : The query results cannot be enumerated more than once
- Get value from dynamic field with Linq
- Susbtring from a data table column
- LINQ pull records from a database where string list is from a model
- C# foreach looping and matching. Is there a faster way to do this?
- Calculate the percentage of empty attributes in an object list
- What is LINQ to events a.k.a RX Framework?
- Removing taken numbers from a List
- LINQ Getting The Next Row ID?
- linq join with groupby and max issues
- How to get Index of an Item in ICollection<T>
- Linq ConcurrentDictionary Roles and Users Many to Many
- How to convert all date-formatted cells in IRange to DateTime using Spreadsheet Gear C#?