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 Articles
- 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
- How to convert NUMBER(9) to String with Linq to Entity?
- Print out Linq Expression Tree Hierarchy
- Linq with alias
- Dynamic linq not correctly apply on list of DynamicClass
- Cross apply in Linq
- How to read date from text file, assign it to date and remove duplicate date in C# Linq
- In Controller, return records with [verified_date] older than 3 months from current date?
- Apply multiple expression in linq
- C# LinqToExcel, Distinct showing all results - tried online solutions, couldn't solve
- Linq Union: How to add a literal value to the query?
- Adding an element to an XML-document with a previously newly created string from an attribute node
- Linq C# Groupby on datatable
- Input Text File and Read First Character of Each Line + Count Occurences
- GroupBy with Count
- search firstname from combination of lastname+", "+firstname using linq
- Adding an XElement with and specify a namespace
- Cannot iterate of a collection of Anonymous Types created from a LINQ Query in VB.NET
- C# Linq Convert Object Property to Array
- Data Access Layer - LINQ-To-SQL and generics. Can I optimize this?
- Linq one Result from multiple Lists