Click here to Skip to main content
15,905,616 members
Home / Discussions / C#
   

C#

 
GeneralRe: SMTP Client - amount of bytes send out of attached files. Pin
fracalifa17-Feb-10 3:45
fracalifa17-Feb-10 3:45 
GeneralRe: SMTP Client - amount of bytes send out of attached files. Pin
Rozis17-Feb-10 10:15
Rozis17-Feb-10 10:15 
AnswerRe: SMTP Client - amount of bytes send out of attached files. Pin
Ennis Ray Lynch, Jr.17-Feb-10 10:29
Ennis Ray Lynch, Jr.17-Feb-10 10:29 
Questioncontrol mouse and keyboard of remote machine. Pin
Tridip Bhattacharjee17-Feb-10 2:01
professionalTridip Bhattacharjee17-Feb-10 2:01 
AnswerRe: control mouse and keyboard of remote machine. Pin
sanforjackass17-Feb-10 2:15
sanforjackass17-Feb-10 2:15 
GeneralRe: control mouse and keyboard of remote machine. Pin
Tridip Bhattacharjee17-Feb-10 18:57
professionalTridip Bhattacharjee17-Feb-10 18:57 
GeneralRe: control mouse and keyboard of remote machine. Pin
sanforjackass17-Feb-10 20:40
sanforjackass17-Feb-10 20:40 
AnswerRe: control mouse and keyboard of remote machine. Pin
Dave Kreskowiak17-Feb-10 3:20
mveDave Kreskowiak17-Feb-10 3:20 
AnswerRe: control mouse and keyboard of remote machine. Pin
sksaininet25-Dec-10 20:02
sksaininet25-Dec-10 20:02 
Questionnet use [modified] Pin
arsendem17-Feb-10 1:31
arsendem17-Feb-10 1:31 
AnswerRe: net use Pin
OriginalGriff17-Feb-10 1:35
mveOriginalGriff17-Feb-10 1:35 
GeneralRe: net use Pin
hammerstein0517-Feb-10 1:36
hammerstein0517-Feb-10 1:36 
AnswerRe: net use Pin
hammerstein0517-Feb-10 1:35
hammerstein0517-Feb-10 1:35 
QuestionC++ to CSharp Pin
Xmen Real 17-Feb-10 1:11
professional Xmen Real 17-Feb-10 1:11 
AnswerRe: C++ to CSharp Pin
Covean17-Feb-10 1:28
Covean17-Feb-10 1:28 
AnswerRe: C++ to CSharp Pin
hammerstein0517-Feb-10 1:29
hammerstein0517-Feb-10 1:29 
AnswerRe: C++ to CSharp Pin
OriginalGriff17-Feb-10 1:32
mveOriginalGriff17-Feb-10 1:32 
GeneralRe: C++ to CSharp [modified] Pin
Xmen Real 17-Feb-10 1:36
professional Xmen Real 17-Feb-10 1:36 
GeneralRe: C++ to CSharp Pin
hammerstein0517-Feb-10 1:41
hammerstein0517-Feb-10 1:41 
GeneralRe: C++ to CSharp Pin
OriginalGriff17-Feb-10 1:42
mveOriginalGriff17-Feb-10 1:42 
GeneralRe: C++ to CSharp [modified] Pin
Xmen Real 17-Feb-10 1:49
professional Xmen Real 17-Feb-10 1:49 
GeneralRe: C++ to CSharp Pin
OriginalGriff17-Feb-10 3:11
mveOriginalGriff17-Feb-10 3:11 
Xmen W.K. wrote:
OriginalGriff wrote:
And please, don't use "magic numbers" - they make code really difficult to follow and maintain.
where ??


public static uint CRCRC(string text)
 {
     uint retHash = 0;
     int a = 0;
     byte[] bytes = System.Text.Encoding.ASCII.GetBytes(text);

     if (bytes[0] == 34)
         a = 1;

     for (; a < bytes.Length; a++)
     {
         byte val = bytes[a];
         if (val == 34)
             break;
         if (val - 65 > 25)
         {
             if (val == 92)
                 val = 47;
         }
         else
             val += 32;
         retHash = (1025 * (retHash + val) >> 6) ^ 1025 * (retHash + val);
     }
     return 32769 * (9 * retHash ^ (9 * retHash >> 11));
 }
34, 65, 25, 92, 47, 32 - these are all "magic numbers". Wiki - see Unnamed numerical constants here.[^] So called because they are necessary to the code but there is no explanation as to what the hell they are or do!
Looking at the original C++ code there is also a magic number 32769 - why? Does this have anything to do with the length of an int?
I am not convinced that the original code actually works (or even compiles): what is textLen[i] doing? textLen is a size_t (which is an unsigned int) not an array.

Try this[^] - I don't know that it works, I haven't tried it, but it is at least written in C# and looks like a CRC32 algorithm!
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace

GeneralRe: C++ to CSharp Pin
Xmen Real 17-Feb-10 3:17
professional Xmen Real 17-Feb-10 3:17 
GeneralRe: C++ to CSharp Pin
OriginalGriff17-Feb-10 3:32
mveOriginalGriff17-Feb-10 3:32 
GeneralRe: C++ to CSharp Pin
Xmen Real 17-Feb-10 15:46
professional Xmen Real 17-Feb-10 15:46 

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.