Introduction
In this article we will learn how to remove comma's from a string using c#. Remove unnecessary comma from a string.
Previous Updates
In previous articles we have learnt Transaction Commit and Rollback in sql server with example.What is Blocking and Deadlock In SQL.
Description
If you have a string with extra comma's separated and you need a exact formatted string separated by single comma then this will be a best solution for you.
Input
,,Your Name,,,Instance ,Transaction Number, Number
,First Name,Last Name,Destination Type,Destination,,Status,,,
|
Solution
string input = ",,Your Name,,,Instance ,Transaction Number, Number
,First Name,Last Name,Destination Type,Destination,,Status,,,";
string output = String.Join(",",input.Split(new[] { ',' },
StringSplitOptions.RemoveEmptyEntries)
);
|
OutPut -
Your Name,Instance ,Transaction
Number, Number,First Name,Last Name,Destination Type,Destination,Status
|
Also Read - Insert only numeric values in Texbox. AngularJS advancement of AngularJs .
0 comments:
Post a Comment