Veröffentlicht 3. März 200520 j Hallo, label9.Text = (DateTime.Now.TimeOfDay - Ergebnis.TimeOfDay).ToString().Substring(0,8); ich möchte gerne den Wert der in label9.text steht in eine Integer Variabel(zb.a) haben. Wie lautet dann die syntax?
3. März 200520 j try{ int a = Convert.toInt32(label.text); }catch(*weiß ich momentan nicht auswendig*){ }
22. März 200520 j try{ int a = Convert.toInt32(label.text); }catch(*weiß ich momentan nicht auswendig*){ } Probiers man mit }catch(Exception e){ Der fängt alle Exceptions ab!
22. März 200520 j Ansonsten hier aus der MSDN: FormatException: value does not consist of an optional sign followed by a sequence of digits (zero through nine). OverflowException: value represents a number less than MinValue or greater than MaxValue.
23. März 200520 j try{ int a = Convert.toInt32(label.text); }catch(*weiß ich momentan nicht auswendig*){ } Alternativ ginge auch: int a = int.parse(label.text);
24. März 200520 j ginge auch und beschreibt die ursprüngliche Methode um die es sich aus der Sicht des .Net Frameworks aus handelt. "int" ist lediglich ein alias Werttyp von c# der auf "System.Int32" im Framework verweist. ganz praktisch, weil einfacher zu tippen..
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.