score:10
Accepted answer
You can use string.Replace which has an overload specifically for this.
var newString = oldString.Replace("foo", string.Empty);
This takes your oldString, finds all occurrences of "foo" and removes them.
score:4
Use extension methods:
public static class StringExtensions
{
public static string RemoveOccurences(this string s, string occurence)
{
return s.Replace(occurence, "");
}
}
usage:
string s = "Remove all appearances of this and that and those";
s.RemoveOccurences("th");
score:5
This would work
var s = "string";
s = s.Replace("st", string.Empty);
// s == "ring";
Is that not correct?
Source: stackoverflow.com
Related Query
- Linq filter List<string> where it contains a string value from another List<string>
- LINQ Source Code Available
- How do i use filter in linq against non string fields?
- Linq or string filter
- Filter a string using LINQ
- creating Linq to sqlite dbml from DbLinq source code
- linq to entities changing database connection string in code
- How to filter by enum from string in LINQ C#
- source code for LINQ 101 samples
- How to filter string in C# using linq to exclude all letters and numbers?
- Filter list of entity objects by string child object property using Linq Lambda
- Creating a dynamic EF filter that builds a LINQ Where equals/contains statement for any string entity property
- Filter a generic list with a dynamic condition string with linq
- Filter a Generic list using LINQ using a PropertyName as a string literal - Using dynamics
- LINQ : filter multiple string values - partial match - not full match as in multiple online examples
- Filter a Dictionary by value where value is a list of string using LINQ
- List or Array of String Contain specific word in Html Source Code
- Simple linq question: How to filter a source afterwards?
- LINQ filter string with value string
- how to translate a linq expression into sql string use c# code
- c# Linq or code to extract groups from a single list of source data
- How to convert a string to C# code in the SELECT of C# LINQ
- Filter LINQ To Entities (EF Core) query by List of HashSet of String and Enum
- Trying to filter only digits in string array using LINQ
- I want to convert a filter string from given string(sql server supported filter) format to linq acceptable filter format
- How do I convert a linq expression to Azure Table Filter String in .NET Core?
- Linq Statement Returns Max Lengths of all Columns Filter Other Than String Type
- How Filter Binding Source Connected To linq Query
- Suggestions on how to optimize code for ordering by string in linq
- Convert string[] to int[] in one line of code using LINQ
More Query from same tag
- Select rows based on group by counts
- Reduce columns selected by EF Core
- C# LINQ Find List Inside Another List, Better way to code this than a foreach loop
- Left Outer join with Linq without DefaultIfEmpty
- Reading either byte[] or float with Linq to Entities
- select two properties in an array of obj
- How to refactor Linq Group By and Foreach statement into one Linq Query
- Insert linq-to-sql problem?
- Compare two generic lists using Linq
- Predicate inside a Where<> query not hit?
- Assign Mapped Object to Expression Result in LINQ to Entities
- MVC4 Linq Database Call
- Combining multiple dictionary where key matches
- No parameterless constructor defined for this object ASP.NET Website
- How can I combine this code into one or two LINQ queries?
- C# multiple joins and not existing in another table
- Add Role to a User just as they Register
- How can I set up a conditional C# if statement and LINQ where statement?
- How to add a conditional statement within an Enumerable method?
- Union two lists of object but remove duplicates based on different values
- Is it possible to select multiple variables with LINQ without using keyword new?
- Get specific value from datatable with where-clause
- Use lambda syntax to retrieve a property from an anonymous type in vb.net
- Replace element tag keep its children
- Better way to write Linq Where statement
- LINQ: Grouping SubGroup
- how to return a property based on another property condition using LINQ in .NET Core
- LINQ Dynamic Where - string parameter missing
- List<T> to a Dictionary
- Linq Group By on Sets