15,885,216 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by veen_rp (Top 15 by date)
veen_rp
22-Jan-16 8:29am
View
I leave this solution in because of the use of linq that was new to me. But this is not a solution. See my follow-up 3 in the original post
veen_rp
22-Jan-16 8:18am
View
I tried this out myself. Though elegant, the execution is slow!! In fact much slower than my initial code. See the update of my original question for the timing of processing 3,506,820 byte arrays like this...
veen_rp
22-Jan-16 1:44am
View
I picked answer 1 and 4 but thanks for the reactions of everyone. I tested out the code of phil.o and it surely works in C#. I'm working now on the conversion to VB.NET which is not trivial because the bit shift operators work a bit differently for the two languages (for those interested: http://stackoverflow.com/questions/8151333/binary-shift-differences-between-vb-net-and-c-sharp). I will combine phil.o extensions with the Unpack function from F.Xaver in solution 4 but not use the BitConverter class for reasons of Endianess. I will post my wrap up in VB.NET here once I got the VB bitshi(f)t going. Tnx!!
veen_rp
21-Jan-16 12:19pm
View
True. I'm in the middle of testing stuff out. Let you know what the result is (any month now...)
veen_rp
21-Jan-16 6:51am
View
This looks good as well, I'll try it out. Though I think, having to combine BitConverter with Endianness, I'm better of with solution 1. Thanks anyway!
veen_rp
21-Jan-16 6:48am
View
Also, the advantage of phil.o approach is that I can write dedicate extensions for BigEndian and LittleEndian. Hmm, interesting, I'll ponder over this...
veen_rp
21-Jan-16 6:43am
View
I think Sascha is right in pointing out the performance penalty is in the array.copy
Thanks sofar, in the coming time I will try this out.
veen_rp
21-Jan-16 6:11am
View
But thanks anyway! KISS is good, KISS + quicker is better... I indeed already have defined a class representing the target structure, I left it out for sake of simplicity wrt the question. This is, together with BitConverter already quite fast. I just want it faster...
Cheers!
veen_rp
21-Jan-16 6:03am
View
As I said in my original question: "Answers in C# are welcome too of course"... Just takes me a little longer, but I'll get there... :)
veen_rp
21-Jan-16 5:57am
View
Thanks, sounds good. I didn't think of an extension yet. I'll wait for some more reactions, but I'm going to try this out to see if it will speed up things.
Rgds.
veen_rp
20-Jan-16 14:23pm
View
Yep, you answered just fine. I'm an old programmer who used to program C on unix (yes, with those difficult *pointers); no catching exceptions then, only returning -1, 0 or 1 and ocasionally an exotic 3... I'm happy .Net is around, it is exciting. In any case I should have followed the advise of CHill60 and just test it out myself empirically; it is not rocket science. Thanks for your links again, they are worth reading it. Is there a button I can press to close the question as solved?
veen_rp
20-Jan-16 11:26am
View
Sergey, thanks for your links. I had now time to look at them. It is clear to me now. In my code in the original question, if I comment out the 'Return False' line, indeed the compiler doesn't complain that 'a result is not returned on all code paths', which proves your point. The local catching of an exception was never part of my question. Indeed, best seems to catch exceptions 'as high' as possible or as generically as possible. Which is not always easy to do. I have withdrawn my solution selected, although to me the answer was straightforward and clear to me. I didn't realize selecting a solution would cascade like this. It was my first question on this forum. Hopefully not my last, if I can find the courage :). Rgds.
veen_rp
20-Jan-16 8:45am
View
Thanks for the answer. Man, I'll think twice before posting another questions. To me it was just a bit of a mental exercise. Nothing ado with abuse and all the rest I got accused of. Didn't expect such hotheads... I should have sticked to your empirical solution in the first place :)
Anyways I'm enjoying the day very much in sunny Holland at the moment. Hope the same for you
veen_rp
20-Jan-16 3:48am
View
To Sergey: please forgive my ignorance as to what is and what is not abusive in the ethics of the Codeproject. In addition: what is the proper way to answer and close a question? If you are going to be angry with me, then you don't have to answer...
veen_rp
20-Jan-16 3:44am
View
Thanks CHill60, good point! I love empirical evidence; it was just a question which stayed in the back of my mind :). Thanks to all commentators. I think my question is answered and closed. For some of you: friendliness costs nothing...
Show More