Conversion de object vers string[]

Résolu
sandra26 Messages postés 92 Date d'inscription mercredi 5 juillet 2006 Statut Membre Dernière intervention 5 août 2009 - 25 mars 2007 à 11:09
sandra26 Messages postés 92 Date d'inscription mercredi 5 juillet 2006 Statut Membre Dernière intervention 5 août 2009 - 25 mars 2007 à 12:28
Salut,

j'ai un array arrColors comme ceci:
string

[] arrColors
= {"red", "orange", "yellow", "green", "blue", "indigo", "violet"};

je travail en asp.net et je voudrais par la suite utiliser la ligne suivante:

arrColors =  ViewState["Colors"];

seulement ca me genere une erreur "Cannot implicitly convert type 'object' to 'string[]' "
Comment  puis-je faire?

sandra

2 réponses

cs_coq Messages postés 6349 Date d'inscription samedi 1 juin 2002 Statut Membre Dernière intervention 2 août 2014 101
25 mars 2007 à 12:21
Salut,

arrColors =  ViewState["Colors"] as String[];
if ( arrColors != null )
{
   // ...
}

/*
coq
MVP Visual C#
CoqBlog
*/
3
sandra26 Messages postés 92 Date d'inscription mercredi 5 juillet 2006 Statut Membre Dernière intervention 5 août 2009
25 mars 2007 à 12:28
ok super ca marche merci bcp

sandra
0
Rejoignez-nous