Tracer
Tracer
CC#
Created by Tracer on 12/25/2024 in #help
Serialize HashSet into a binary file
Hello. I want to serialize a hashset into a binary file. I tried using BinaryFormatter but its obsolete. I dont want to save it as xml or json but as pure bytes. How could I do it?
enum Test {
A = 1,
B = 2,
C = 3
}

HashSet<Test> set = new HashSet<Test>();

set.Add(Test.A);
set.Add(Test.C);
set.Add(Test.B);

// How to do that?
Serialize(set, "myfile.bin");
enum Test {
A = 1,
B = 2,
C = 3
}

HashSet<Test> set = new HashSet<Test>();

set.Add(Test.A);
set.Add(Test.C);
set.Add(Test.B);

// How to do that?
Serialize(set, "myfile.bin");
218 replies