Announcement

Collapse
No announcement yet.

Byte als 2-stellige Hex-Zahl ausgeben ?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Byte als 2-stellige Hex-Zahl ausgeben ?

    Hallo,
    ich habe eine Textbox in der ein Bytewert als 2-stellige Hexadezimalzahl angezeigt werden soll. Folgender Code gibt aber nur 1 anstatt 01 aus.

    Code:
    byte bValue = 1;
    textbox_Byte.Text = bValue.ToString("X");
    Es sollte wie beim Stringbuilder funktionieren:

    Code:
    sbText.AppendFormat("{0:X}", bValue);
    Halt nur mit String.

    Hat jemand nen Tip?

    Dannke schon mal.

    Gruß i865

  • #2
    Hallo,

    die trivialen Lösung hast nicht probiert Die wären
    • in der Doku unter ToString nachschauen -> dort müsste ein Beispiel sein die das zeigt
    • x2 probiert
    .

    [highlight=c#]
    string s = b.ToString("x2");
    [/highlight]
    liefert das gewünschte Ergebnis.


    mfG Gü
    "Any fool can write code that a computer can understand. Good programmers write code that humans can understand". - Martin Fowler

    Comment


    • #3
      Hallo,

      ich danke dir.

      Gruß i865

      Comment

      Working...
      X