Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to convert?
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
How to convert?
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01615029
Message ID:
01615029
Vues:
45
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform