Announcement

Collapse
No announcement yet.

structur serialisiren

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

  • structur serialisiren

    Hallo Experten,
    ich möchte anhand der Serialization eine Sructur in ein Bytearray umwandeln, ist das möglich ???
    Wenn ja kann mir jemand helfen dies zu realisieren ?
    Danke Für Eure nette Hilfe

    Gruß

    BigPier

  • #2
    Hallo,

    ja ist möglich in folgendes Beispiel zeigt wie:
    [highlight=c#]
    using System;
    using System.IO;
    using System.Runtime.Serialization.Formatters.Binary;

    namespace ConsoleApplication1
    {
    class Program
    {
    static void Main(string[] args)
    {
    Foo foo = new Foo { Zahl = 3 };
    BinaryFormatter binFormatter = new BinaryFormatter();
    byte[] buffer;
    using (MemoryStream ms = new MemoryStream())
    {
    binFormatter.Serialize(ms, foo);
    buffer = ms.ToArray();
    }
    }
    }

    [Serializable]
    struct Foo
    {
    public int Zahl { get; set; }
    }
    }
    [/highlight]

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

    Comment


    • #3
      Danke für Deine schnelle Antwort werde gleich Probieren ob ich es Verstehe !!!

      Mfg
      Bigpier

      Comment


      • #4
        Hallo,
        leider verstehe ich das obige Beispiel nicht richtig könnte jemand so nett sein und mir auf die sprünge helfen ?
        Auf diesem Weg möchte ich mich für meine Dumheit endschuldigen bin leider Anfänger!!
        Gruß
        Bigbier

        Comment


        • #5
          Hallo,

          dann empfehle ich erstmals als Lektüre das Galileo Openbook und danach stellst du die Frage nochmals und gibts an was genau du nicht verstehst.


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

          Comment

          Working...
          X