Autor Beitrag
pflaumenlaub
Hält's aus hier
Beiträge: 5



BeitragVerfasst: Mo 26.01.09 21:00 
ausblenden C#-Quelltext
1:
2:
3:
4:
int i = 300000000 ;
i = Convert.ToInt32(textBox1.Text);
string a = String.Format("{0:X08}", i);
textBox4.Text = a


Guten Abend,

Hab hier ein kleines Programm geschrieben.
Das wandelt die zahl 300000000 in eine Hexdezimal zahl um.
Funktioniert auch alles einwandfrei.

300000000 = 11E1A300 // Das Programm gibt das aus, was auch richtig ist.

Jetzt zu meiner Frage:

Ich möchte die Ausagbe von meiner Hex-Zahl: 11 E1 A3 00 bisschen
durcheinander bringen, undzwar soll die Ausgabe so schauen: 00 A3 E1 11
Weiß einer Rat?

MfG

Moderiert von user profile iconChristian S.: C#-Tags hinzugefügt
Christoph1972
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 690
Erhaltene Danke: 16


VS2015 Pro / C# & VB.Net
BeitragVerfasst: Mo 26.01.09 23:41 
Hi,


habe mal kurz was zusammengebaut. Aber ich denke da wird es noch eine bessere Lösung geben.

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
private String Change(String OldValue)
{            
    String NewValue = "";
    Char[] CharArray = OldValue.ToCharArray();
   
    for (Int32 I = CharArray.Length - 1; I >= 0; I--)
    {
      NewValue += CharArray[I];
    }
    return NewValue;
}



Gruß
Christoph
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19340
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 27.01.09 00:02 
Wie wäre es einfach so:
ausblenden C#-Quelltext
1:
2:
3:
4:
int i = 300000000;
i = (i >> 24) + ((i & 0x00FF0000) >> 8
    + ((i & 0x0000FF00) << 8) + ((i & 0x000000FF) << 24);
textBox1.Text = String.Format("{0:X08}", i);
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Di 27.01.09 14:53 
Oder etwas deklarativer:
ausblenden C#-Quelltext
1:
2:
csharp> string.Join(" ", Array.ConvertAll(BitConverter.GetBytes(300000000), b => b.ToString("X2")));
"00 A3 E1 11"

Oder, wenn Bindestriche nicht stören, einfach BitConverter.ToString.

_________________
>λ=