Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to convert?
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
How to convert?
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01615029
Message ID:
01615029
Views:
46
UPDATE. This compiles
Select(val=>new KeyValuePair<string, string> (val.ListItemValue.ToString(), val.ListItemText)).ToList();
Testing now.
--------------------------------------------------------------------------------
Hi everybody,

I need to have List of KeyValuePair as a result.

This is my current code
typeCriteria.PossibleValues = EnumUtilities.EnumToEnumViewModel<TemplateTypes>(selectEnumValue: TemplateTypes.Pass, omitEnumValue: TemplateTypes.NotSpecified);
and this is the error I am getting:
Error	1	Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<SysManager.Common.Models.EnumViewModel>' to 'System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<string,string>>'. An explicit conversion exists (are you missing a cast?)	c:\_siriusware\main\sysmanager\sysmanager.web\areas\items\controllers\templatesapicontroller.cs	73	47	SysManager.Web
where EnumViewModel is
public class EnumViewModel
    {
        public virtual bool Selected { get; set; }
        public virtual string ListItemText { get; set; }
        public virtual Int32 ListItemValue { get; set; }
    }
How can I fix the syntax above to get List of KeyValuePair?

Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform