score:4
Accepted answer
var strlist = new list<string>();
var colist = strlist.select(item => new customobject() {name = item}).tolist();
score:2
edit: removed rubbish class declaration
ilist<string> names = new list<string> { "first name", "second name" };
ilist<sampleobject> myobjects =
names.select(x => new sampleobject { name = x }).tolist();
score:3
try the following:
list<customobject> customobjectlist =
(from item in stringlist
select new customobject { name = item, emailaddress = string.empty }).tolist();
Source: stackoverflow.com
Related Query
- creating Linq to sqlite dbml from DbLinq source code
- c# Linq or code to extract groups from a single list of source data
- Create a list from two object lists with linq
- Favorite way to create an new IEnumerable<T> sequence from a single value?
- How do I dynamically create an Expression<Func<MyClass, bool>> predicate from Expression<Func<MyClass, string>>?
- Create a list of one object type from a list of another using Linq
- How to create a csv file from List<String[]>
- Create combined DataTable from two DataTables joined with LINQ. C#
- Create a list from another list
- How to create LINQ Query from string?
- Create Items from 3 collections using Linq
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- Accessing Results View from variable in code
- How to create a dynamic LINQ select projection function from a string[] of names?
- Generating the Shortest Regex Dynamically from a source List of Strings
- How Do I Create an Expression<Func<>> with Type Parameters from a Type Variable
- How to understand the following C# linq code of implementing the algorithm to return all combinations of k elements from n
- Is it possible to create one dimension array from two using LINQ?
- How to create hierarchy in json string from string array?
- How to create a complex type from a stored procedure that uses exec()?
- What is the best way to create strongly typed LINQ queries from some given strings, via reflection
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- Create an XML from a DataTable
- How to pass LinQ Expressions from F# to C# code
- Create and initialize dictionary from list
- LINQ: Can we create a flat list from hierarchy
- LINQ query to create a collection of objects combined from a collection of strings
- Using LINQ to delete an element from a ObservableCollection Source
- Create a nested list of items from objects with a parent reference
- How to create SQL Database from Linq2Sql Model
More Query from same tag
- Why does Linq not provide a lambda parameter instead of IEqualityComparer<T>?
- LINQ query using lambda expression
- Linq - where not in comma separated list
- How to get filtered record from LINQ - VB.net
- Grouping data with datatable with ASP.NET
- Why does the Contains() operator degrade Entity Framework' Linq queries?
- C# LINQ make any take 2 or more from array
- ASP.NET/XML/LINQ: Extract Attribute from Element
- LINQ pass in value for each iteration
- feature list out and throw it into the foreach
- LINQ - select from two arrays
- Null check in Linq query expression
- Is there a way to watch LINQ queries as they happen?
- c#- Convert DataTable to List, and Count a particular column into Linq form
- query never returning results - "Enumeration yielded no results"
- Find last word in upper case from array
- Calling functions in a LINQ query
- System.InvalidCastException for DataModel Creation using Sqlite as Database
- LINQ: Dynamic .Where() Statements
- ILookup with empty collections
- Cannot call method of type A with parameter type A?
- Convert string to decimal in group join linq query
- Conditional Joins With Linq
- C# LINQ SQL EntityFramework challenge
- How to Convert Items of Dropdownlist to datetime?
- Is there any consideration while comparing Enums in LINQ-to-NHibernate or LINQ?
- Linq search with several keywords
- LINQ Where clause with Contains where the list has complex object
- Select all fields from collection with related items in another collection using LINQ
- Removing a Dictionary Entry With a Regex