score:2
first, it seems like you are trying to instantiate a list object with a constructor that takes in a string[] returned from split(). list<> constructors take either ienumerables or ints to determine size, but there is no c# list<> constructor that takes in a string[].
second, you for some reason have a tostring() method attached to your list<> reference. i believe this will return a hexadecimal string for your memory location.
instead of this complicated string, try doing something like this:
list<string> lsttags = new list<string>():
if(!(string.isnullorempty(f.tagname))
lsttags.addrange(f.tagname.split(',');
addrange() adds an array of objects returned from a statement.
score:7
if you add "using system.linq;", you could use .tolist() to turn the string array that .split() returns into a list.
list<string> lsttags = (string.isnullorempty(f.tagname) ? new list<string>() :
f.tagname.split(',').tolist());
or, if you didn't mind the small inefficiency of calling .split() and .tolist() when f.tagname is null, then you could use the null-coalescing operator (??):
list<string> lsttags = (f.tagname ?? "").split(',').tolist();
Source: stackoverflow.com
Related Query
- How to check for null values before Converting a comma Separated string to Generic List
- How to check for null before I use in linq?
- How to unpack an expression tree and check for null values
- How can I check for null values in this linq query where clause
- How to check comma separated values stored in data base column having the given value using linq in c#
- How to check string for null and assign its value in the same line
- c# linq how to check for null values in the same column that i need to be not null
- How to pass comma separated values to LINQ query without for loop
- How to check for null and empty string in Exression.Constant?
- How can I write a generic extension method for converting a delimited string to a list?
- How to create a comma delimited string from distinct list of values using LINQ?
- Linq query, how to check for a null value and use the value 0 in place of a null?
- How to turn array into quote and comma delimited string for sql?
- How can I check for a null inside of a linq query?
- Issue with query returning null before I can check for null
- How to check for null attributes in LinqToXML expressions?
- How to Select the Token and Index from a Comma Separated String in Linq
- How to compare 2 comma seperated string values and update in existing list at same position?
- DB4o Linq query - How to check for null strings
- LINQ check string property for NULL in generating a ToList()
- How can I get a comma separated list of values from a List using LINQ?
- Check for null before select on linq
- How to check for null in collection
- Find index of item from string array containing comma separated values
- How to check if dt.AsEnumerable is Null before copying it UIPATH
- How to send column data as a comma separated string from stored procedure?
- How to check for null on Nullable types using Linq expression in Realm?
- How to check for results in query before performing aggregate operation?
- Check null condition for string date conversion to DateTime inside object
- How can I omit NULL values when converting DataRow to a Dictionary in C#?
More Query from same tag
- C# Code Optimization GroupBy
- Group by and count in C# w/ Console.WriteLine
- Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<AnonymousType#1>' to 'System.Collections.Generic.List<CUSTOM DATA TYPE>
- When called from 'VisitLambda', rewriting a node of type 'System.Linq.Expressions.ParameterExpression' must return a non-null value of the same type
- ForEach extension method
- C# Building Json string, but I'm getting the error "Invalid anonymous type member declarator"
- Filter generic list with generic dictionary
- Linq - Creating Expression<T1> from Expression<T2>
- Is LINQ Join operator using Nested Loop, Merge, or HashSet Joins?
- A specified Include path is not valid. The EntityType 'SpiceShop.Models.Product' does not declare a navigation property with the name 'Products'
- Get a iqueryable items which do not exists on another list using lambda expression
- Linq version of SQL "IN" statement
- Linq method equivalent for "Into"
- Linq OrderBy on generic list returns not entirely alphabetical list
- What is the C# extension methods equivalent for this Linq query?
- Doesn't IQueryable.Expression = Expression.Constant(this); cause an infinite loop?
- Error in selecting value from RavenDB
- Linq with dot notation - which is better form or what's the difference between these two?
- How to use orderby with 2 fields in linq?
- Linq to dataset and display linq result in repeater control
- Linq Except completes fast on some tables but not others
- What is the Linq Query expression to get all the department Id , Name in a select list variable for drop down
- How get selected listitems using linq - lambda syntax?
- Why Linq query doesn't return records when querying against partition key in Cosmos Db?
- LINQ to Entites grouping by columns belonging to multiple entities
- Merge nested objects in one list using Linq
- The more "SQL-syntax" of Linq.Except
- Compare two list using linq in C#
- LINQ to SQL debug visualizer for VS 2012?
- How can I add and remove records from a collection with LINQ