You absolutely can convert the sbyte to a byte I can pretty much guarantee you that the Java code will really be treating the byte array as unsigned. (Or to put it another way: base64 is only defined in terms of unsigned bytes...) Just convert to byte and call Convert. ToBase64String Converting to byte is actually really easy - although C# itself doesn't provide a conversion between the two, the CLR is quite happy to perform a reference conversion, so you just need to fool the C# compiler: sbyte x = { -1, 1 }; byte y = (byte) (object) x; Console.
WriteLine(Convert. ToBase64String(y)) If you want to have a genuine byte you can copy: byte y = new bytex. Length; Buffer.
BlockCopy(x, 0, y, 0, y. Length) but personally I'd stick with the first form.
You absolutely can convert the sbyte to a byte - I can pretty much guarantee you that the Java code will really be treating the byte array as unsigned. (Or to put it another way: base64 is only defined in terms of unsigned bytes...) Just convert to byte and call Convert. ToBase64String.
Converting to byte is actually really easy - although C# itself doesn't provide a conversion between the two, the CLR is quite happy to perform a reference conversion, so you just need to fool the C# compiler: sbyte x = { -1, 1 }; byte y = (byte) (object) x; Console. WriteLine(Convert. ToBase64String(y)); If you want to have a genuine byte you can copy: byte y = new bytex.
Length; Buffer. BlockCopy(x, 0, y, 0, y. Length); but personally I'd stick with the first form.
Quick. Somebody throw me a link to john skeet facts. Just kidding.Respect.
– TigOldBitties Sep 5 at 20:00 It does make sense, as the Convert. ToBase64String uses pointers to get the binary representation... And it is a pattern... – NoProblemBabe Sep 7 at 1:54 @NoProblemBabe: Pointers are really pretty irrelevant here, to be honest... – Jon Skeet Sep 7 at 5:23 What do you mean? – NoProblemBabe Sep 8 at 13:42 @NoProblemBabe: I mean that it would make sense whether or not Convert.
ToBase64String used pointers. That's an internal implementation detail. – Jon Skeet Sep 8 at 13:43.
Class Program { static void Main() { sbyte signedByteArray = { -2, -1, 0, 1, 2 }; byte unsignedByteArray = (byte)(Array)signedByteArray; Console. WriteLine(Convert. ToBase64String(unsignedByteArray)); } }.
Sorry mate, using that dual casting quite often I receive an error about a mismatch array type. Specially using nhibernate. But thanks – NoProblemBabe Sep 7 at 1:56 I've seen that ther's a convertall method in the Array class, where you can, by lambda, cast each item – NoProblemBabe Sep 9 at 15:03.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.