Click here to Skip to main content
15,440,991 members
Home / Discussions / C#
   

C#

 
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
MemberStefan 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
MemberStefan Troschuetz31-Jul-07 4:41 
GeneralRe: Strange behavior of comparison with double.PositiveInfinity Pin
PhilDanger31-Jul-07 4:54
MemberPhilDanger31-Jul-07 4:54 
GeneralRe: Strange behavior of comparison with double.PositiveInfinity Pin
Stefan Troschuetz31-Jul-07 9:06
MemberStefan Troschuetz31-Jul-07 9:06 
QuestionWriting a Type to Binary File Pin
JamesBarnes31-Jul-07 0:56
MemberJamesBarnes31-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
MemberJamesBarnes31-Jul-07 1:11 
Questionhow to make sure Socket has connected? Pin
Gavin Roberts31-Jul-07 0:56
MemberGavin Roberts31-Jul-07 0:56 
AnswerRe: how to make sure Socket has connected? Pin
led mike31-Jul-07 4:21
Memberled mike31-Jul-07 4:21 
GeneralRe: how to make sure Socket has connected? Pin
Gavin Roberts31-Jul-07 5:08
MemberGavin Roberts31-Jul-07 5:08 
GeneralRe: how to make sure Socket has connected? Pin
led mike31-Jul-07 5:41
Memberled mike31-Jul-07 5:41 
GeneralRe: how to make sure Socket has connected? Pin
Gavin Roberts31-Jul-07 6:08
MemberGavin Roberts31-Jul-07 6:08 
GeneralRe: how to make sure Socket has connected? Pin
pbraun31-Jul-07 8:45
Memberpbraun31-Jul-07 8:45 
GeneralRe: how to make sure Socket has connected? Pin
led mike31-Jul-07 9:06
Memberled mike31-Jul-07 9:06 
QuestionUnrecognized attribute 'xmlns' Pin
kalyan_241631-Jul-07 0:46
Memberkalyan_241631-Jul-07 0:46 
AnswerRe: Unrecognized attribute 'xmlns' Pin
Vasudevan Deepak Kumar31-Jul-07 0:58
MemberVasudevan Deepak Kumar31-Jul-07 0:58 
AnswerRe: Unrecognized attribute 'xmlns' Pin
prasanna muthuramalingam31-Jul-07 1:42
Memberprasanna muthuramalingam31-Jul-07 1:42 
GeneralRe: Unrecognized attribute 'xmlns' Pin
kalyan_241631-Jul-07 1:52
Memberkalyan_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
Memberdeepaksringr31-Jul-07 0:21 

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.