Click here to Skip to main content
15,915,172 members
Home / Discussions / C#
   

C#

 
QuestionCursor Size Pin
jojoba20118-Aug-11 18:02
jojoba20118-Aug-11 18:02 
AnswerRe: Cursor Size Pin
Dave Kreskowiak8-Aug-11 19:58
mveDave Kreskowiak8-Aug-11 19:58 
QuestionCursor Size Pin
jojoba20118-Aug-11 20:29
jojoba20118-Aug-11 20:29 
AnswerRe: Cursor Size Pin
BobJanova9-Aug-11 0:37
BobJanova9-Aug-11 0:37 
QuestionBindingsource Question Pin
Davey_guan8-Aug-11 15:41
Davey_guan8-Aug-11 15:41 
AnswerRe: Bindingsource Question Pin
Qendro8-Aug-11 23:26
Qendro8-Aug-11 23:26 
GeneralRe: Bindingsource Question Pin
Davey_guan9-Aug-11 16:50
Davey_guan9-Aug-11 16:50 
Questioncant get this part of my program to produce the correct result Pin
stephen.darling8-Aug-11 11:45
stephen.darling8-Aug-11 11:45 
Hello.
I have one more question, as I can not get this last function to work properly.

It takes a string of digits, of any length, like "123456789" and converts it to a byte array which is the base-10 encoding.

So if we pass the above string "123456789" into the function, we should get a byte array back which would be:

0x75BCD15 -> the hex value for the above string.

I will be passing strings between 40 and 80 digits long. And I should mention I ported the code from c++, so made some changes to get it to compile.

It does produce a correct length byte array, but the hex values are never correct.

The function is...

byte[] DecodeRequestCode(string requestCode, int ResLen)
        {
            int Sum = 0;
            int Digit, Aux, m;
            byte[] result = new byte[17];

            for (int i = 0; i < 7; i++) // I know it is 7 here, as I was trying a 8 digit number, will edit this later
            {
                Digit = requestCode[i] - '0';

                Aux = Digit;
                m = 0;

                do
                {
                    Aux += result[m] *10;
                    result[m++] = (byte) (Aux & 255);

                    Aux >>= 8;

                }
                while (m < ResLen);

                //if ((k & 1) != 0)
                //    Digit *= 2;

                Sum += Digit;

            }

            return result;

        }


I will be extreamly gratefull if someone could find out what I am doing wrong, and if possible, how I would reverse it to write a function that will produce the string of digits from the byte array?

Thank you again,
Kind Regards,

Stephen
AnswerRe: cant get this part of my program to produce the correct result Pin
PIEBALDconsult8-Aug-11 15:37
mvePIEBALDconsult8-Aug-11 15:37 
GeneralRe: cant get this part of my program to produce the correct result Pin
stephen.darling9-Aug-11 4:22
stephen.darling9-Aug-11 4:22 
GeneralRe: cant get this part of my program to produce the correct result Pin
Matt Meyer9-Aug-11 4:57
Matt Meyer9-Aug-11 4:57 
GeneralRe: cant get this part of my program to produce the correct result Pin
stephen.darling9-Aug-11 5:54
stephen.darling9-Aug-11 5:54 
AnswerRe: cant get this part of my program to produce the correct result Pin
PIEBALDconsult8-Aug-11 16:35
mvePIEBALDconsult8-Aug-11 16:35 
AnswerRe: cant get this part of my program to produce the correct result Pin
BobJanova9-Aug-11 0:31
BobJanova9-Aug-11 0:31 
GeneralRe: cant get this part of my program to produce the correct result Pin
stephen.darling9-Aug-11 4:21
stephen.darling9-Aug-11 4:21 
GeneralRe: cant get this part of my program to produce the correct result Pin
BobJanova9-Aug-11 7:27
BobJanova9-Aug-11 7:27 
GeneralRe: cant get this part of my program to produce the correct result Pin
stephen.darling9-Aug-11 8:18
stephen.darling9-Aug-11 8:18 
GeneralRe: cant get this part of my program to produce the correct result Pin
BobJanova9-Aug-11 10:03
BobJanova9-Aug-11 10:03 
GeneralRe: cant get this part of my program to produce the correct result Pin
stephen.darling9-Aug-11 10:38
stephen.darling9-Aug-11 10:38 
Questionprofeesional sample oop project with c# Pin
mehran.asg8-Aug-11 10:56
mehran.asg8-Aug-11 10:56 
AnswerRe: profeesional sample oop project with c# Pin
Richard Andrew x648-Aug-11 11:43
professionalRichard Andrew x648-Aug-11 11:43 
AnswerRe: profeesional sample oop project with c# Pin
DaveyM698-Aug-11 12:29
professionalDaveyM698-Aug-11 12:29 
AnswerRe: profeesional sample oop project with c# Pin
Dr.Walt Fair, PE8-Aug-11 17:56
professionalDr.Walt Fair, PE8-Aug-11 17:56 
AnswerRe: profeesional sample oop project with c# Pin
PIEBALDconsult8-Aug-11 18:25
mvePIEBALDconsult8-Aug-11 18:25 
QuestionConvert Dll c#2 to WOrk on C#4 Pin
md_refay8-Aug-11 8:24
md_refay8-Aug-11 8:24 

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

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