Click here to Skip to main content
15,888,610 members
Home / Discussions / C#
   

C#

 
AnswerRe: Using directive Pin
J4amieC31-Jul-07 3:05
J4amieC31-Jul-07 3:05 
AnswerRe: Using directive Pin
PIEBALDconsult31-Jul-07 10:21
mvePIEBALDconsult31-Jul-07 10:21 
GeneralRe: Using directive Pin
Albu Marius31-Jul-07 22:01
Albu Marius31-Jul-07 22:01 
GeneralRe: Using directive Pin
PIEBALDconsult1-Aug-07 13:52
mvePIEBALDconsult1-Aug-07 13:52 
GeneralRe: Using directive Pin
Albu Marius2-Aug-07 1:20
Albu Marius2-Aug-07 1:20 
GeneralRe: Using directive Pin
PIEBALDconsult2-Aug-07 15:12
mvePIEBALDconsult2-Aug-07 15:12 
QuestionDataGridView Pin
sangramkp31-Jul-07 1:26
sangramkp31-Jul-07 1:26 
AnswerRe: DataGridView Pin
Herman<T>.Instance31-Jul-07 2:56
Herman<T>.Instance31-Jul-07 2:56 
QuestionNUnit and relative Paths Pin
User 665831-Jul-07 1:25
User 665831-Jul-07 1:25 
Questionconvertion from word file into pdf file Pin
adilkazmi31-Jul-07 1:14
adilkazmi31-Jul-07 1:14 
AnswerRe: convertion from word file into pdf file Pin
ekynox31-Jul-07 2:36
ekynox31-Jul-07 2:36 
AnswerRe: convertion from word file into pdf file Pin
Not Active31-Jul-07 2:36
mentorNot Active31-Jul-07 2:36 
QuestionStrange behavior of comparison with Double.IsPositiveInfinity [modified] Pin
Stefan Troschuetz31-Jul-07 1:13
Stefan Troschuetz31-Jul-07 1:13 
AnswerRe: Strange behavior of comparison with double.PositiveInfinity Pin
Luc Pattyn31-Jul-07 1:30
sitebuilderLuc Pattyn31-Jul-07 1:30 
GeneralRe: Strange behavior of comparison with double.PositiveInfinity Pin
Stefan Troschuetz31-Jul-07 2:31
Stefan Troschuetz31-Jul-07 2:31 
GeneralRe: Strange behavior of comparison with double.PositiveInfinity Pin
Luc Pattyn31-Jul-07 2:50
sitebuilderLuc Pattyn31-Jul-07 2:50 
GeneralRe: Strange behavior of comparison with double.PositiveInfinity Pin
Stefan Troschuetz31-Jul-07 3:11
Stefan Troschuetz31-Jul-07 3:11 
GeneralRe: Strange behavior of comparison with double.PositiveInfinity Pin
Luc Pattyn31-Jul-07 3:36
sitebuilderLuc Pattyn31-Jul-07 3:36 
GeneralRe: Strange behavior of comparison with double.PositiveInfinity Pin
Stefan Troschuetz31-Jul-07 4:23
Stefan Troschuetz31-Jul-07 4:23 
JokeRe: Strange behavior of comparison with double.PositiveInfinity Pin
Luc Pattyn31-Jul-07 4:36
sitebuilderLuc Pattyn31-Jul-07 4:36 
GeneralRe: Strange behavior of comparison with double.PositiveInfinity Pin
Stefan Troschuetz31-Jul-07 4:41
Stefan Troschuetz31-Jul-07 4:41 
GeneralRe: Strange behavior of comparison with double.PositiveInfinity Pin
PhilDanger31-Jul-07 4:54
PhilDanger31-Jul-07 4:54 
GeneralRe: Strange behavior of comparison with double.PositiveInfinity Pin
Stefan Troschuetz31-Jul-07 9:06
Stefan Troschuetz31-Jul-07 9:06 
QuestionWriting a Type to Binary File Pin
JamesBarnes31-Jul-07 0:56
JamesBarnes31-Jul-07 0:56 
AnswerRe: Writing a Type to Binary File Pin
Luc Pattyn31-Jul-07 1:08
sitebuilderLuc Pattyn31-Jul-07 1:08 
Hi,

BinaryWriter.Write() has overloads for all kinds of native data types, including
int and string. Of course it does not know your class.

If you have a Weapon class, you could add a Write(BinaryWriter) method it,
that would perform a number of basic BinaryWriter.Write() calls so everything
that needs to be written gets written. And of course you would have to
also add a Read method; you might make that one static and have it return a
new instance of Weapon.

The next problem may consist of understanding you binary file; if it consists
of a number of records, each containing the data for one out of many possible
types, you must somehow decide which classe's Read must be invoked next.

One way of solving this is by adding a static bool Recognize(BinaryReader) method,
that does not modify the stream's position, but determines if the data corresponds
with that class.

And it typically is helpful to start each record with something unique,
often called an eyecatcher. It could be a single character ('W' for weapon),
an enum value, whatever. In doing so, you could have a general ReadFile() method
that peeks at the next eyecatcher, then calls the right Read() method, and
loops over this until the file is done.

Smile | :)


General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.