Avoir un objet grace à un string en c#
Fermé
glob04d
-
24 juin 2010 à 14:45
Krysstof Messages postés 1483 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 1483 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 objet occasion entre particulier - Guide
- Lancez l'application. envoyez ce mail à manon (manon@pixmail.org) en mettant en copie nina (nina@pixmail.org) : objet : colis bonjour, votre colis est arrivé. que répond manon ? ✓ - Forum Loisirs / Divertissements
- Ouvrez ce fichier avec un éditeur de texte simple (bloc-notes, textedit, gedit, …) pour y découvrir le nom d'un objet. ✓ - Forum Études / Formation High-Tech
- Cannot access offset of type string on string - Forum PHP
- Objet requis vba - Forum VB / VBA
5 réponses
Krysstof
Messages postés
1483
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
377
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
1483
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"]);