Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Create SelectList C# Extension
WhatsApp
Bhavik Patel
Jul 31
2016
4.9
k
0
0
Extension
public
static
IEnumerable<SelectListItem> CreateSelectList<T>(
this
List<T> entities, Func<T,
object
> value, Func<T,
object
> text)
{
return
entities.Select(x =>
new
SelectListItem
{
Value = value(x).ToString(),
Text = text(x).ToString()
});
}
How to use it,
userList.CreateSelectList(x => x.Id, x => x.Name)
SelectList
C#
Extensions
Up Next
Create SelectList C# Extension