Click here to Skip to main content
Licence 
First Posted 17 Jun 2004
Views 75,078
Bookmarked 19 times

Object ByteArray Converter

By | 17 Jun 2004 | Article
this dll help users to convert between any object and byte array which will be very useful when using to insert objects into a DataBase

Introduction

this dll help users to convert between any object and byte array which will be very useful when using to insert objects into a DataBase.(specialy images)

it contain two main methods

ObjectToByteArray:

       which accept an object and return array of bytes .

ByteArrayToObject:

      which accept an array of bytes and return object.

why I make this dll?

I need in a project on automatic exam system in my work (Scientific calculation Center,Mansoura University,Egypt) to insert into database an custum object of exam data.

I'm sure that I can find a solution to this problem by add Exam Details table to my dataBase

but I hope to  use the first strategy ,So I make it.

keywords

Database,converter,image,byte array

      

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Tamer Ahmed Farrag



Egypt Egypt

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionProblem while converting PinmemberMuneswar22:18 3 Oct '07  
Generalproblem with some objects Pinmemberjag_Dalton2:00 22 Feb '07  
GeneralRe: problem with some objects PinmemberDrPhilz1:55 28 Jun '07  
GeneralHuge problem with the methods PinmemberKasracer1:38 26 Jan '06  
Take this example.
 
When using encryption in .Net, you use mostly byte arrays. Now if you want to encrypt an object using your methods, you'd first take the object and serialize it (thus, converting it to a byte[]). Now you pass that to your encryption routines and you're done.
 
Now, let's say you add the result to an ArrayList, which automatically puts the byte[] into a System.Object.
 
What do you do when you want to decrypt it? You have to have it in byte[] from. If you attempt to use your ObjectToByteArray method, it'll attempt to serialize it again thus making it practically impossible to ever get the original data.
 
You can try to cast the Object to a byte[], which sometimes works (I've done many tests) but it isn't 100%.
 
So these methods will work with some things, but they are not very reliable especially for encryption.
 
Also, please use the using statements with any variable that has an IDisposable base. That way everything is cleaned up immediately and you don't even need a finally statement.
 
BinaryIdiot.com - great source for news and software.
GeneralRe: Huge problem with the methods Pinmemberjigar_dotnet2:13 4 Apr '07  
QuestionConvert from object to byte array problem Pinmemberanalyzer29:48 19 Jan '06  
AnswerRe: Convert from object to byte array problem PinmemberKasracer1:40 26 Jan '06  
GeneralRe: Convert from object to byte array problem Pinmemberanalyzer21:55 26 Jan '06  
GeneralRe: Convert from object to byte array problem PinmemberKasracer23:37 30 Jan '06  
GeneralRe: Convert from object to byte array problem Pinmemberanalyzer20:25 31 Jan '06  
GeneralRe: Convert from object to byte array problem Pinmemberdonjefe14:54 3 Aug '06  
Generalnice one! PinmemberCodeGimp23:23 26 Jun '05  
QuestionArticle justified? Pinmemberjmw2:16 18 Jun '04  
AnswerRe: Article justified? PinmemberTamer Ahmed Farrag2:47 18 Jun '04  
GeneralI update the article PinmemberTamer Ahmed Farrag23:54 17 Jun '04  
QuestionWhy this way? Pinmembermav.northwind20:19 17 Jun '04  
AnswerRe: Why this way? PinmemberTamer Ahmed Farrag21:42 17 Jun '04  
GeneralRe: Why this way? Pinmembermav.northwind22:08 17 Jun '04  
GeneralRe: Why this way? Pinmemberjmw2:11 18 Jun '04  
GeneralRe: Why this way? PinsussMihies3:28 19 Jun '04  
GeneralRe: Why this way? Pinmemberjmw4:16 19 Jun '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120529.1 | Last Updated 18 Jun 2004
Article Copyright 2004 by Tamer Ahmed Farrag
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid