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

C#

 
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 | :)


GeneralRe: Writing a Type to Binary File Pin
JamesBarnes31-Jul-07 1:11
JamesBarnes31-Jul-07 1:11 
Questionhow to make sure Socket has connected? Pin
Gavin Roberts31-Jul-07 0:56
Gavin Roberts31-Jul-07 0:56 
AnswerRe: how to make sure Socket has connected? Pin
led mike31-Jul-07 4:21
led mike31-Jul-07 4:21 
GeneralRe: how to make sure Socket has connected? Pin
Gavin Roberts31-Jul-07 5:08
Gavin Roberts31-Jul-07 5:08 
GeneralRe: how to make sure Socket has connected? Pin
led mike31-Jul-07 5:41
led mike31-Jul-07 5:41 
GeneralRe: how to make sure Socket has connected? Pin
Gavin Roberts31-Jul-07 6:08
Gavin Roberts31-Jul-07 6:08 
GeneralRe: how to make sure Socket has connected? Pin
pbraun31-Jul-07 8:45
pbraun31-Jul-07 8:45 
GeneralRe: how to make sure Socket has connected? Pin
led mike31-Jul-07 9:06
led mike31-Jul-07 9:06 
QuestionUnrecognized attribute 'xmlns' Pin
kalyan_241631-Jul-07 0:46
kalyan_241631-Jul-07 0:46 
AnswerRe: Unrecognized attribute 'xmlns' Pin
Vasudevan Deepak Kumar31-Jul-07 0:58
Vasudevan Deepak Kumar31-Jul-07 0:58 
AnswerRe: Unrecognized attribute 'xmlns' Pin
prasanna muthuramalingam31-Jul-07 1:42
prasanna muthuramalingam31-Jul-07 1:42 
GeneralRe: Unrecognized attribute 'xmlns' Pin
kalyan_241631-Jul-07 1:52
kalyan_241631-Jul-07 1:52 
QuestionHow to get installed products on a system Pin
Yosh_31-Jul-07 0:41
professionalYosh_31-Jul-07 0:41 
AnswerRe: How to get installed products on a system Pin
Luc Pattyn31-Jul-07 1:00
sitebuilderLuc Pattyn31-Jul-07 1:00 
GeneralRe: How to get installed products on a system Pin
Yosh_1-Aug-07 3:41
professionalYosh_1-Aug-07 3:41 
GeneralRe: How to get installed products on a system Pin
Luc Pattyn1-Aug-07 3:53
sitebuilderLuc Pattyn1-Aug-07 3:53 
QuestionProblem in mdi form Pin
deepaksringr31-Jul-07 0:21
deepaksringr31-Jul-07 0:21 
AnswerRe: Problem in mdi form Pin
Martin#31-Jul-07 0:44
Martin#31-Jul-07 0:44 
GeneralRe: Problem in mdi form Pin
deepaksringr31-Jul-07 0:58
deepaksringr31-Jul-07 0:58 
AnswerRe: Problem in mdi form Pin
Yosh_31-Jul-07 0:55
professionalYosh_31-Jul-07 0:55 

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.