Search code examples
c#oracletype-conversionnumericbinarywriter

A custom binarywriter or a custom numeric datatype?


I have to query an oracle database for various numeric values and dump them with my c# console app in a binary file with a custom format. Depending on the business data I need to encode the numeric value on 1 byte length,2 byte length,3 byte length,4,6,8,10 and 16... As for now I think that I could store the 1 byte as a char or a byte value type and write with the standard binarywriter. For the 2 byte length I could use a short value type, etc... But I am pretty sure that there is no native .Net numeric type for the 3 byte length, the 10 byte length and so on... So I am trying to find how to query the values (from oracle as string ?) and binary write them... The two solutions I have in mind : write a custom binarywriter or try to find how to create some custome numeric type class (something like Byte10,Byte16...) but both solutions seems akwards.... How would you have deal with that problem? Please do not advise to switch to c/c++ as I do not really know those languages...

Thank you for any help.


Solution

  • Yes it is all about managing a custom byte[] and I think I have found what I was looking for here