const WhiteSpace = [#32, #10, #13, #9];
and check memership like this:
if c in WhiteSpace then...
but I don't know how, using arrays is an alternative, but I need something
faster and easier to play with. Any ideas?
Another problem I'm having is reading from a stream (System.IO.FileStream).
The BeginRead method takes a byte array, but I need to read words (2 bytes)
in order to compare some values, so is there something like BlockRead from
Delphi?
Regards
Marko
For enumerations, use an integer type and the bit wise operators.
> Another problem I'm having is reading from a stream
> (System.IO.FileStream).
> The BeginRead method takes a byte array, but I need to read words (2
> bytes)
> in order to compare some values, so is there something like BlockRead from
> Delphi?
There isn't. C#, and the whole dotnet, is a type safe environment. You have
to rebuild each data type from the array of byte. In you example, to rebuild
a word, you read the low byte, then the high vyte (assuming words are
written in that order which is the native order for Intel processors), your
word is the high byte multiplyed by 256 and added to the low byte.
You can derive from FileStream and implement methods to read various
datatypes you need.
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
francoi...@overbyte.be
The author for the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be
I know of that approach, but bitwise operations work with powers of 2, how
would you do it with numbers like 9, 10, 13 and 32 - they have to be like
that cause they're character codes ('\t', '\n', '\r', ' ') and using some
constants would just reduce the speed of the program. Or am I wrong about
this? How do Delphi sets work anyway (I mean internally, I know how to use
them)?
> There isn't. C#, and the whole dotnet, is a type safe environment. You
> have to rebuild each data type from the array of byte. In you example, to
> rebuild a word, you read the low byte, then the high vyte (assuming words
> are written in that order which is the native order for Intel processors),
> your word is the high byte multiplyed by 256 and added to the low byte.
I thought so, thanks anyway.
Regards
Marko
For set of ordinal type, I think Delphi use the equivalent "case-of". Have a
look at the assembly code generated by Delphi.
> Another problem I'm having is reading from a stream
> (System.IO.FileStream). The BeginRead method takes a byte array, but
> I need to read words (2 bytes)
It sounds like you need the System.BitConverter class, in particular
the BitConverter.ToUInt16(byte[] value, int startIndex) method.
--
Cheers,
David Clegg
dcl...@gmail.com
http://cc.borland.com/Author.aspx?ID=72299
QualityCentral. The best way to bug Borland about bugs.
http://qc.borland.com
"I'm not a bad guy! I work hard, and I love my kids. So why should I
spend half my Sunday hearing about how I'm going to Hell?" - Homer
Simpson