Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
GeneralRe: Starting a new project in C# Pin
FilipJ17-Feb-14 0:02
FilipJ17-Feb-14 0:02 
AnswerRe: Starting a new project in C# Pin
Ravi Bhavnani17-Feb-14 7:49
professionalRavi Bhavnani17-Feb-14 7:49 
AnswerRe: Starting a new project in C# Pin
David C# Hobbyist.17-Feb-14 12:15
professionalDavid C# Hobbyist.17-Feb-14 12:15 
QuestionStruct vs Class? PinPopular
David C# Hobbyist.16-Feb-14 12:34
professionalDavid C# Hobbyist.16-Feb-14 12:34 
AnswerRe: Struct vs Class? Pin
Peter Leow16-Feb-14 13:29
professionalPeter Leow16-Feb-14 13:29 
AnswerRe: Struct vs Class? PinPopular
OriginalGriff16-Feb-14 21:29
mveOriginalGriff16-Feb-14 21:29 
GeneralRe: Struct vs Class? Pin
Nicholas Marty16-Feb-14 21:55
professionalNicholas Marty16-Feb-14 21:55 
GeneralRe: Struct vs Class? Pin
harold aptroot16-Feb-14 22:02
harold aptroot16-Feb-14 22:02 
GeneralRe: Struct vs Class? Pin
OriginalGriff16-Feb-14 22:17
mveOriginalGriff16-Feb-14 22:17 
GeneralRe: Struct vs Class? Pin
OriginalGriff16-Feb-14 22:26
mveOriginalGriff16-Feb-14 22:26 
GeneralRe: Struct vs Class? Pin
harold aptroot16-Feb-14 22:59
harold aptroot16-Feb-14 22:59 
GeneralRe: Struct vs Class? Pin
OriginalGriff17-Feb-14 0:06
mveOriginalGriff17-Feb-14 0:06 
GeneralRe: Struct vs Class? Pin
harold aptroot17-Feb-14 0:16
harold aptroot17-Feb-14 0:16 
GeneralRe: Struct vs Class? Pin
jschell17-Feb-14 12:07
jschell17-Feb-14 12:07 
GeneralRe: Struct vs Class? Pin
BillWoodruff17-Feb-14 1:41
professionalBillWoodruff17-Feb-14 1:41 
AnswerStruct vs Class? (Off Topic) Pin
OriginalGriff17-Feb-14 0:41
mveOriginalGriff17-Feb-14 0:41 
GeneralRe: Struct vs Class? (Off Topic) Pin
David C# Hobbyist.17-Feb-14 11:12
professionalDavid C# Hobbyist.17-Feb-14 11:12 
GeneralRe: Struct vs Class? (Off Topic) Pin
OriginalGriff17-Feb-14 11:24
mveOriginalGriff17-Feb-14 11:24 
GeneralRe: Struct vs Class? (Off Topic) Pin
OriginalGriff23-Feb-14 0:29
mveOriginalGriff23-Feb-14 0:29 
GeneralRe: Struct vs Class? (Off Topic) Pin
David C# Hobbyist.23-Feb-14 4:42
professionalDavid C# Hobbyist.23-Feb-14 4:42 
GeneralRe: Struct vs Class? (Off Topic) Pin
OriginalGriff23-Feb-14 4:57
mveOriginalGriff23-Feb-14 4:57 
QuestionInterface for Authorization Custom Inteface c# Winforms .net 4.0 Pin
Member 1050351416-Feb-14 12:10
Member 1050351416-Feb-14 12:10 
AnswerRe: Interface for Authorization Custom Inteface c# Winforms .net 4.0 Pin
Eddy Vluggen17-Feb-14 0:29
professionalEddy Vluggen17-Feb-14 0:29 
QuestionStrange bug when converting from binary to decimal.. Pin
Alex Reed16-Feb-14 9:54
Alex Reed16-Feb-14 9:54 
Hello all. I recently finished a homework assignment which involves creating a fully functioning calculator in c# which can also take the integers which are being displayed and convert them to binary, and then vice versa via radio controls.

My convert2decimal function isn't working correctly though. Say I input 999 into the window, it will output the correct binary value of
1111100111
But then when i click the radio button to convert that value from the text box back to decimal, instead if 999 i get 927.
Also yes i am aware that i could simply declare a variable to hold the original decimal value, but i doubt my instructor would look upon that fondly.
Here is the offending code snippet
C#
private void convert2Decimal(string value)
       {
          String binaryDigits = value;
          char []  Binary = binaryDigits.ToCharArray(); // new array filled with a binary digit for each indice, in char form. Will need to be Parsed

          long dValue = 0;                                    // int array to recieve parsed strings
          int superscript = display.Text.Length - 1;          // Value which will hold the power of 2 based on how many indices there are
          int bValue = 1;
          if (superscript > 0)
          {
               foreach (char element in Binary )
              {
                  Console.WriteLine((long)char.GetNumericValue(element));
                  if ((long)char.GetNumericValue(element) == 1)
                  {
                    Console.WriteLine(  dValue += ((long)char.GetNumericValue(element)) * bValue);     //assigns the char converted to integer to the int dValue

                  }bValue *= 2;

              }
              display.Text =""+ dValue;
          }


Even more strange behavior is that, when converting the wrong value of 927 back to binary via the binary conversion, i get the correct binary value of 927, but when i finally click the decimal conversion, it shows a value of 999...!Confused | :confused:
AnswerRe: Strange bug when converting from binary to decimal.. Pin
Richard Andrew x6416-Feb-14 11:25
professionalRichard Andrew x6416-Feb-14 11:25 

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.