Click here to Skip to main content
15,899,679 members
Home / Discussions / C#
   

C#

 
AnswerRe: How would I go about implementing this in my code/program? PinPopular
Chris Quinn22-Aug-17 23:09
Chris Quinn22-Aug-17 23:09 
AnswerRe: How would I go about implementing this in my code/program? Pin
OriginalGriff22-Aug-17 23:23
mveOriginalGriff22-Aug-17 23:23 
AnswerRe: How would I go about implementing this in my code/program? Pin
Pete O'Hanlon23-Aug-17 0:00
mvePete O'Hanlon23-Aug-17 0:00 
AnswerRe: How would I go about implementing this in my code/program? Pin
Gerry Schmitz23-Aug-17 6:38
mveGerry Schmitz23-Aug-17 6:38 
GeneralRe: How would I go about implementing this in my code/program? Pin
Eddy Vluggen23-Aug-17 7:01
professionalEddy Vluggen23-Aug-17 7:01 
GeneralRe: How would I go about implementing this in my code/program? Pin
Gerry Schmitz24-Aug-17 5:26
mveGerry Schmitz24-Aug-17 5:26 
GeneralRe: How would I go about implementing this in my code/program? Pin
Richard MacCutchan24-Aug-17 5:50
mveRichard MacCutchan24-Aug-17 5:50 
GeneralRe: How would I go about implementing this in my code/program? Pin
Gerry Schmitz26-Aug-17 8:08
mveGerry Schmitz26-Aug-17 8:08 
GeneralRe: How would I go about implementing this in my code/program? Pin
Eddy Vluggen24-Aug-17 6:38
professionalEddy Vluggen24-Aug-17 6:38 
AnswerRe: How would I go about implementing this in my code/program? Pin
Bernhard Hiller23-Aug-17 21:16
Bernhard Hiller23-Aug-17 21:16 
Questionintel Hex file creator from Txt File Pin
Psudonym21-Aug-17 21:31
Psudonym21-Aug-17 21:31 
QuestionRe: intel Hex file creator from Txt File Pin
Richard MacCutchan21-Aug-17 21:37
mveRichard MacCutchan21-Aug-17 21:37 
AnswerRe: intel Hex file creator from Txt File Pin
OriginalGriff21-Aug-17 21:41
mveOriginalGriff21-Aug-17 21:41 
AnswerRe: intel Hex file creator from Txt File Pin
Psudonym21-Aug-17 21:48
Psudonym21-Aug-17 21:48 
GeneralRe: intel Hex file creator from Txt File Pin
OriginalGriff21-Aug-17 22:20
mveOriginalGriff21-Aug-17 22:20 
AnswerRe: intel Hex file creator from Txt File Pin
Luc Pattyn21-Aug-17 23:14
sitebuilderLuc Pattyn21-Aug-17 23:14 
GeneralRe: intel Hex file creator from Txt File Pin
Psudonym22-Aug-17 1:31
Psudonym22-Aug-17 1:31 
GeneralRe: intel Hex file creator from Txt File Pin
OriginalGriff22-Aug-17 1:48
mveOriginalGriff22-Aug-17 1:48 
GeneralRe: intel Hex file creator from Txt File Pin
Psudonym22-Aug-17 17:22
Psudonym22-Aug-17 17:22 
GeneralRe: intel Hex file creator from Txt File Pin
Luc Pattyn22-Aug-17 1:56
sitebuilderLuc Pattyn22-Aug-17 1:56 
AnswerRe: intel Hex file creator from Txt File Pin
Psudonym22-Aug-17 18:13
Psudonym22-Aug-17 18:13 
Guys,

I could solve the problem.
This is the solution...

        private string ToHexString(string str)
        {
            var sb = new StringBuilder();

            var bytes = Encoding.Unicode.GetBytes(str);
            //foreach (var t in bytes)
            //{
            //    sb.Append(t.ToString("X"));
            //}

            for(int i=0; i<str.Length; i++)
            {
                byte b = (byte)str[i];
                sb.Append(b.ToString("X"));
            }

            return sb.ToString(); 
        }
    }
}


However, this has opened up new problem. Poke tongue | ;-P
Now the checksum is wrong Frown | :(

When I pass string "
Quote:
:107830003132313131303031323331323334363120
"
for checksum calculation, the expected o/p is 0x2B however the function returns "20".
this is the function...

private string GetChecksum(string strData)
       {
           byte checksum = 0;
           char[] DataArray = strData.ToCharArray();
           byte ArrayLen = 0;
           string strAscii;

           //Add all bytes of the string
           while (ArrayLen < strData.Length)
           {
               if ((DataArray[ArrayLen]) != ':')
               {
                   checksum += (byte)DataArray[ArrayLen];
               }
               ArrayLen++;
           }

           //1's complement of the addition
           checksum = (byte)(~(int)checksum);

           //2's complement of the addition
           checksum += 1;

           strAscii = ((checksum & 0xF0) >> 4).ToString("X") + (checksum & 0x0F).ToString("X");
           return strAscii;
       }


When I debug the problem, I could see, the function received first 1 in string as 31. I know that is the problem, it should receive first 10 as 10 and not as 31 30
GeneralI want to display this method into graphics form inside Private void VtfGraphicalViewMode(Graphics graphics){} Pin
Member 1321093321-Aug-17 8:09
Member 1321093321-Aug-17 8:09 
GeneralRe: I want to display this method into graphics form inside Private void VtfGraphicalViewMode(Graphics graphics){} Pin
OriginalGriff21-Aug-17 20:04
mveOriginalGriff21-Aug-17 20:04 
Questionhow can I add data to datatable and bind it to datagridview c# Pin
ali nagi20-Aug-17 17:27
ali nagi20-Aug-17 17:27 
AnswerRe: how can I add data to datatable and bind it to datagridview c# Pin
Mycroft Holmes20-Aug-17 20:38
professionalMycroft Holmes20-Aug-17 20:38 

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.