Avoir un objet grace à un string en c#
Fermé
glob04d
-
24 juin 2010 à 14:45
Krysstof Messages postés 1489 Date d'inscription mercredi 18 février 2009 Statut Membre Dernière intervention 23 août 2010 - 24 juin 2010 à 15:20
Krysstof Messages postés 1489 Date d'inscription mercredi 18 février 2009 Statut Membre Dernière intervention 23 août 2010 - 24 juin 2010 à 15:20
A voir également:
- Avoir un objet grace à un string en c#
- Vente entre particulier objet - Guide
- Identifier un objet à partir d'une photo - Guide
- Objet interdit en cabine ryanair - Guide
- Mesurer un objet - Guide
- Vous ne pouvez pas déplacer des objets en dehors de la feuille ✓ - Forum Excel
5 réponses
Krysstof
Messages postés
1489
Date d'inscription
mercredi 18 février 2009
Statut
Membre
Dernière intervention
23 août 2010
294
24 juin 2010 à 14:49
24 juin 2010 à 14:49
juste pour confirmation,
System.Drawing.Imaging.ImageFormat.png est un type
"System.Drawing.Imaging.ImageFormat.png" est une chaine de caractère.
quand tu dit "sortelist("jpg") me retourne l'objet System.Drawing.Imaging.ImageFormat.jpeg
"
tu veux quoi exactement en retour, le nom du type, une chaine de caractère représentant le nom du type, ou un objet vide de ce type?
System.Drawing.Imaging.ImageFormat.png est un type
"System.Drawing.Imaging.ImageFormat.png" est une chaine de caractère.
quand tu dit "sortelist("jpg") me retourne l'objet System.Drawing.Imaging.ImageFormat.jpeg
"
tu veux quoi exactement en retour, le nom du type, une chaine de caractère représentant le nom du type, ou un objet vide de ce type?
en fait c'est pour mettre dans cette fonction la :
string cheminphoto = "C:\\...."
myBitmapResize.Save(cheminphoto, sortelist("jpg")).
Vu que save me demande:
(string string, System.Drawing.Imaging.ImageFormat format)
string cheminphoto = "C:\\...."
myBitmapResize.Save(cheminphoto, sortelist("jpg")).
Vu que save me demande:
(string string, System.Drawing.Imaging.ImageFormat format)
chuka
Messages postés
965
Date d'inscription
samedi 11 octobre 2008
Statut
Membre
Dernière intervention
29 juillet 2010
378
24 juin 2010 à 15:07
24 juin 2010 à 15:07
Salut,
utilise un hashtable...
ashtable ht = new Hashtable();
ht.Add("jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
ht.Add("gif", System.Drawing.Imaging.ImageFormat.Gif);
ht.Add("png", System.Drawing.Imaging.ImageFormat.Png);
ImageFormat t=(ImageFormat)ht["jpg"];
@+
utilise un hashtable...
ashtable ht = new Hashtable();
ht.Add("jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
ht.Add("gif", System.Drawing.Imaging.ImageFormat.Gif);
ht.Add("png", System.Drawing.Imaging.ImageFormat.Png);
ImageFormat t=(ImageFormat)ht["jpg"];
@+
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Krysstof
Messages postés
1489
Date d'inscription
mercredi 18 février 2009
Statut
Membre
Dernière intervention
23 août 2010
294
24 juin 2010 à 15:20
24 juin 2010 à 15:20
Si tu utilse un dictionnaire, tu n'a pas besoin de "typer" ton résultat contrairement a une hashtable
System.Collections.Generic.Dictionary<string, System.Drawing.Imaging.ImageFormat> listetype =
new System.Collections.Generic.Dictionary<string, System.Drawing.Imaging.ImageFormat>();
listetype.Add("jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
listetype.Add("gif", System.Drawing.Imaging.ImageFormat.Gif);
listetype.Add("png", System.Drawing.Imaging.ImageFormat.Png);
myBitmapResize.Save(cheminphoto, listetype["jpg"]);
System.Collections.Generic.Dictionary<string, System.Drawing.Imaging.ImageFormat> listetype =
new System.Collections.Generic.Dictionary<string, System.Drawing.Imaging.ImageFormat>();
listetype.Add("jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
listetype.Add("gif", System.Drawing.Imaging.ImageFormat.Gif);
listetype.Add("png", System.Drawing.Imaging.ImageFormat.Png);
myBitmapResize.Save(cheminphoto, listetype["jpg"]);