Article View: borland.public.csharpbuilder.language.csharp
Article #187Re: Converting from Delphi (sets and streams)
From: Francois PIETTE [ICS - MidWare]
Date: Sun, 29 Oct 2006 12:35
Date: Sun, 29 Oct 2006 12:35
39 lines
2572 bytes
2572 bytes
> I'm trying to convert a personal app from Delphi to C# but I'm having some > trouble finding a C# equivalent for sets. I've been paging through all C# > books I have here and just can't find it. What I want to do is declare a > set > of f.ex. characters: > > 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? 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 -- francois.piette@overbyte.be The author for the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be
Technical Details
Message-ID:
<4544a026$2@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!news.glorb.com!tudelft.nl!txtfeed1.tudelft.nl!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<45448666@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,228682803dcaeb60 X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Francois PIETTE [ICS - MidWare]" <francois.piette@overbyte.be> Newsgroups: borland.public.csharpbuilder.language.csharp References: <45448666@newsgroups.borland.com> Subject: Re: Converting from Delphi (sets and streams) Date: Sun, 29 Oct 2006 13:35:09 +0100 Lines: 42 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 81.244.50.87 Message-ID: <4544a026$2@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1162125350 81.244.50.87 (29 Oct 2006 04:35:50 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!news.glorb.com!tudelft.nl!txtfeed1.tudelft.nl!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail