Autor Beitrag
Ivy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 228



BeitragVerfasst: Mi 20.06.12 14:00 
Hallo zusammen,
wie kann ich eine dezimal zahl in eine hexadezimal zahl umrechnen?
ausblenden C#-Quelltext
1:
string.Format("{0:x}", Befehl);					

hierbei bekomme ich den Fehler "Der Formatbezeichner war ungültig"
LG
IVY


Zuletzt bearbeitet von Ivy am Do 21.06.12 08:32, insgesamt 1-mal bearbeitet
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4764
Erhaltene Danke: 1052

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mi 20.06.12 16:32 
Hallo,

und wo ist das Problem?
Du brauchst doch einfach "mal 50" rechnen. :gruebel:

Edit: Ivy hat in der Zwischenzeit seine Originalfrage gelöscht und eine ganz andere gestellt...


Zuletzt bearbeitet von Th69 am Do 21.06.12 12:24, insgesamt 1-mal bearbeitet
Palladin007
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1282
Erhaltene Danke: 182

Windows 11 x64 Pro
C# (Visual Studio Preview)
BeitragVerfasst: Mi 20.06.12 22:34 
Ich denke, er wollte wissen, wie man die Zahl in einen Hexadezimal-Wert umrechnen kann.

Allerdings nicht theoretisch, sondern im Programm.
Wie man das umrechnet, das weiß ich auch, wie man dann aber das als Programm macht, weiß ich so auf Anhieb jetzt aber auch nicht.
Deshalb kann ich auch nicht helfen. :/
Blawen
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 616
Erhaltene Danke: 33

Win XP, Vista, 7
Delphi 5 Prof., BDS 2006 Prof. RAD Studio XE
BeitragVerfasst: Mi 20.06.12 23:07 
Mit den Suchbegriffen "hex, dez " in der Suche oben rechts findest Du ein paar Ansätze und Lösungen.

_________________
Es kompilert, wir können ausliefern.
Und es kompiliert wieder - das Update ist fertig - bitte 100 Euro ;-)
Ivy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 228



BeitragVerfasst: Do 21.06.12 08:31 
Hey,
ja ich versuche meine zahl so in hex umzuwandeln:

ausblenden C#-Quelltext
1:
string.Format("{0:x}", deczahl);					


kommt aber der fehler "Der Formatbezeichner war ungültig."
mats74
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 189
Erhaltene Danke: 26

Win 10
VS 2017/19, C++, C#
BeitragVerfasst: Do 21.06.12 09:15 
Hallo Ivy

Dein Code ist korrekt:
ausblenden C#-Quelltext
1:
MessageBox.Show(string.Format("{0:x}"123456));					

... ergibt den HEX-Wert 1e240.
Wie ist den deine Variable "deczahl" deklariert?

_________________
Gruss
mats74
Ralf Jansen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 4701
Erhaltene Danke: 991


VS2010 Pro, VS2012 Pro, VS2013 Pro, VS2015 Pro, Delphi 7 Pro
BeitragVerfasst: Do 21.06.12 09:39 
Wenn du Zahl nach String wandeln willst ist wohl eher Convert.ToString() oder Zahltyp.ToString() geeigneter.
Also z.B.
ausblenden C#-Quelltext
1:
decZahl.ToString("X")