score:2
Accepted answer
public static string tohtml(list<int> tags)
{
var found = values.where(v => tags.contains(v.key))
.select(v => v.value.tohtml());
return found.any()
? string.join("", found.toarray()) + " "
: string.empty;
}
score:0
const char space = ' ';
var s = values
.select(v => tags.contains(v.key) ? v.value : string.empty)
.aggregate((v1, v2) => v1 + space + v2)
.trimend(space);
Source: stackoverflow.com
Related Query
- C# LINQ combinatorics: All Combinations of a Set without the Empty Set
- SQL > Linq to Sql, SQL Query works, Linq to SQL returns empty data set
- Code practice to handle empty result set in Linq to custom list
- Empty set in LINQ in C#
- If null then set it to empty string lambda expression in linq
- Linq Expression returning null rather than empty set
- LINQ - Set element in Dictionary to empty where DateTime value is oldest
- IF null or empty set 0 LINQ
- What does LINQ return when the results are empty
- Filling a DataSet or a DataTable from a LINQ query result set
- Checking if a list is empty with LINQ
- Instantiate empty IQueryable for use with Linq to sql
- Using Linq to objects, how to create an empty dictionary of <string, string> easily?
- LINQ syntax where string value is not null or empty
- If Linq Result Is Empty
- Empty namespace using Linq Xml
- C# Linq OrderBy filtering null or empty values to be last
- LINQ Max extension method gives an error on empty collections
- Best practices for dealing with LINQ statements that result in empty sequences and the like?
- find non intersecting data set with linq
- LINQ order by alphabetical followed by empty string
- Using Linq to remove from set where key exists in other set?
- How to do Linq aggregates when there might be an empty set?
- Linq All on empty collection
- How to assign empty string if the value is null in linq query?
- How can I set properties on all items from a linq query with values from another object that is also pulled from a query?
- Converting a resource set into dictionary using linq
- Linq to Sql - Set connection string dynamically based on environment variable
- Why is the sum of an empty set null?
- How to use LINQ to find all combinations of n items from a set of numbers?
More Query from same tag
- GetValue, How to handle null values into a Linq sentence
- Group By, Take First with a vale from second
- Reading the result of LINQ and XDocument
- Find Element when XPath is variable
- Ordered Distinct
- Order by multiple lists of object
- Linq: Explicit construction of entity type in query is not allowed
- c# LINQ returning all joined results
- Entity Framework method group Include does not work
- linq where contains ALL items in list
- EF Core LINQ Where with extension methods are not translated to SQL
- Identical (?) C# and VB.NET LINQ queries return different results
- Converting Data in a C# List from one type to another.
- How to select CompanyName and number of its products?
- Loading data from XML Document throwing a NullReferenceException when using XDocument on Windows Phone 7
- How to use LIKE Operator in LINQ to Entity Framework
- Lambda Expression with a statement body can not been converted
- How can I rewrite this Linq to XML query?
- Optimize XML Reading
- Build pairs out of list - without repetition
- c# Writing an extension method to extend functionality in System.Linq
- how to execute method or DML in foreach loop as parallel to accelarate execution time?
- LINQ grouping by nullable child and parent
- Cannot convert string to DateTime
- Why does this simple LINQ expression NOT work?
- how to pull a null check for `item.GetType().GetProperty(getPropertyStringParameter)` in linq
- C# LINQ query shows and exception when datagridview cell is empty
- Convert Timespan to string in LINQ
- Best resources to learn MVC, Linq, Entity Framework
- Count from List(of List(of myObject))