score:3
Accepted answer
This is not possible with LINQ expressions. You could use the following:
Quantities = numbers.Select((s, index) => new SelectListItem
{
Value = index.ToString(),
Text = s.ToString()
);
score:0
You can use the method syntax instead of the query syntax:
var quantities = numbers.Select((x,i) => {...});
Source: stackoverflow.com
Related Query
- How to get the index of int array when using linq query
- How to use expressions to build a LINQ query dynamically when using an interface to get the column name?
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- How do I get the index of the highest value in an array using LINQ?
- How to get the top 3 elements in an int array using LINQ?
- Get array index values of the top 1000 largest entries inside an array using LINQ
- How can I write the following code more elegantly using LINQ query syntax?
- How to get the value of an XML element using Linq even when empty
- How to get the key when using linq Max() method
- Why did I get an exception "Cannot implicitly convert type 'bool' to 'long?'" when using the LINQ Sum method and how to fix it?
- How to get all the childs using a linq query
- Linq code to get the index of an object in an array from an object within a list
- How to get the array cell position when using foreach across an array?
- How to GroupBy using LINQ query in C# when the key is to be the same type as your type T when grouping List<T>
- how to get first object when the name is the same and Id is different with linq query
- how to get the value using linq query C#
- how do i handle value when the value is null or Empty using linq query
- How to avoid Query Plan re-compilation when using IEnumerable.Contains in Entity Framework LINQ queries?
- Take the first five elements and the last five elements from an array by one query using LINQ
- How to get the TSQL Query from LINQ DataContext.SubmitChanges()
- How to get a byte array length using LINQ to Entities?
- How do I get list of id's as int using LINQ
- Using LINQ To Query Int Ids From An Array
- Using a LINQ Where query to get only some of the ConfigurationManager.ConnectionStrings
- How to get all elements except the n'th element in a List using Linq
- When using a LINQ Where clause on a Dictionary, how can I return a dictionary of the same type?
- How to reuse a linq expression for 'Where' when using multiple source tables
- Linq - Get the Index of the Last Non-Zero Number of Array
- How can I get LINQ to return the index of the object which has the max value in a collection?
- How to find the index of next matching element in list using LINQ
More Query from same tag
- remove chars in string except last
- using Enumerable.Aggregate on System.Collection.Generic.Dictionary
- LINQ left join only works in the ActionResult
- How can I select the value and type of a dynamic list?
- Cannot implicitly convert type 'System.Collections.Generic.IEnumerable>>' to 'System.Collections.Generic.IEnumerable'. An explicit conversion exists
- How to filter related data using Entity Framework and LINQ to SQL and LinqKit PredicateBuilder Or IdeaBlade DevForce
- LINQ Compare two collections on multiple properties
- Select All columns for all tables in join + linq join
- Get Value and Count of that value using LINQ or lambda expression
- How to get max sum range for specific time period from values in Dictionary
- Group data having unique keys and values
- C# LINQ left join 3 Tables/Lists
- Pulling a table from a SQL Server database into a List<> in C# using Entity Framework
- Show only active records and remove expired records using linq c#
- Cannot implicitly convert type 'System.Collections.Generic.List<<anonymous type>>' to 'System.Collections.Generic.List<string>'
- Linq: All With value set and at least one with that value?
- in C#, how do I order items in a list where the "largest" values are in the middle of the list
- LINQ compound select problem
- Linq to Sql Concat Issue
- Returning xml sub elements from attributed elements with LINQ
- Weird extention method behaviour in LINQ query
- Lambda where condition in Join statement
- LINQ with anonymous class/properties
- Conditional Sum in LINQ
- Searching in MVC5 using linq
- How to rewrite duplicate keys in dictionary?
- how to map a computed column in linq to sql classes
- Filtering listbox using textbox using Linq but listbox stays full
- Use Linq Expression object inside and outside query
- Why failed to add item on a session IEnumerable list