Click here to Skip to main content
15,892,674 members
Home / Discussions / C#
   

C#

 
GeneralWhat can you do in destructor with .NET? Pin
devvvy11-Aug-03 2:52
devvvy11-Aug-03 2:52 
GeneralRe: What can you do in destructor with .NET? Pin
James T. Johnson11-Aug-03 10:50
James T. Johnson11-Aug-03 10:50 
GeneralRe: What can you do in destructor with .NET? Pin
Nish Nishant11-Aug-03 15:58
sitebuilderNish Nishant11-Aug-03 15:58 
GeneralUsing a .lib in c# Pin
Big Trev11-Aug-03 1:32
Big Trev11-Aug-03 1:32 
GeneralRe: Using a .lib in c# Pin
Anthony_Yio11-Aug-03 1:56
Anthony_Yio11-Aug-03 1:56 
GeneralConverting Binary to Hex Pin
eggie511-Aug-03 0:26
eggie511-Aug-03 0:26 
GeneralRe: Converting Binary to Hex Pin
Meysam Mahfouzi11-Aug-03 1:16
Meysam Mahfouzi11-Aug-03 1:16 
GeneralRe: Converting Binary to Hex Pin
WillemM11-Aug-03 9:02
WillemM11-Aug-03 9:02 
Hex numbers are composed of 4 bits, since 1111 = F so you need to split the bitstring into pieces of 4 bits wide. Then you need to find the decimal value of these bits. Next you look if the value is < 10 if not then you will need to assign a letter A-F to the value and append that to your result. Else you can simply convert the number to text and append that to your result. The problem you will probably ecounter is that the string is not big enough to split into pieces that all are 4 bits wide. You can simply solve that with a check if(bitString.Length % 4 != 0) .... this will indicate that the string is not long enough!

ArrayList strings;<br />
string result = "";<br />
int tempValue;<br />
int counter;<br />
<br />
strings = new ArrayList();<br />
<br />
for(int i = 0; i < bitString.Length; i += 4)<br />
{<br />
  strings.Add(bitString.Substring(i,4));  <br />
}<br />
<br />
<br />
foreach(string bits in strings)<br />
{<br />
  tempValue = 0;<br />
  counter = 1;<br />
<br />
  for(int j = bits.Length-1; j > 0; j--)<br />
  {<br />
    if(bits[j] == '1')<br />
    {<br />
      tempValue += counter;<br />
    }<br />
<br />
    counter *= 2;<br />
  }   <br />
<br />
  if(tempValue < 10)<br />
  {  <br />
    result += tempValue.ToString();<br />
  }<br />
  else<br />
  {<br />
    switch(tempValue)<br />
    {<br />
      case 10:<br />
        result += "A";<br />
        break;<br />
      case 11:<br />
        result += "B";<br />
        break;<br />
      //....<br />
  }<br />
}


I am sorry for you if there are any mistakes in the code above. This code was written in approx. 30 seconds and not tested. Good luck!!

Greetings.... Smile | :)

QuestionWhat did I click in the treeview Pin
Nick Seng10-Aug-03 23:58
Nick Seng10-Aug-03 23:58 
AnswerRe: What did I click in the treeview Pin
OMalleyW11-Aug-03 1:59
OMalleyW11-Aug-03 1:59 
GeneralRe: What did I click in the treeview Pin
Heath Stewart11-Aug-03 2:20
protectorHeath Stewart11-Aug-03 2:20 
GeneralRe: What did I click in the treeview Pin
Nick Seng11-Aug-03 2:28
Nick Seng11-Aug-03 2:28 
GeneralRe: What did I click in the treeview Pin
Nick Seng11-Aug-03 2:27
Nick Seng11-Aug-03 2:27 
GeneralRe: What did I click in the treeview Pin
OMalleyW11-Aug-03 2:44
OMalleyW11-Aug-03 2:44 
GeneralRe: What did I click in the treeview Pin
Nick Seng11-Aug-03 2:46
Nick Seng11-Aug-03 2:46 
Questionweb service???? Pin
don7cry10-Aug-03 23:28
don7cry10-Aug-03 23:28 
AnswerRe: web service???? Pin
Anthony_Yio11-Aug-03 1:59
Anthony_Yio11-Aug-03 1:59 
Generalinsert statement for ms access Pin
zecodela10-Aug-03 23:01
zecodela10-Aug-03 23:01 
GeneralRe: insert statement for ms access Pin
Nish Nishant10-Aug-03 23:12
sitebuilderNish Nishant10-Aug-03 23:12 
GeneralWhich button was pressed... Pin
eggie510-Aug-03 21:29
eggie510-Aug-03 21:29 
GeneralRe: Which button was pressed... Pin
Meysam Mahfouzi10-Aug-03 22:25
Meysam Mahfouzi10-Aug-03 22:25 
GeneralRe: Which button was pressed... Pin
eggie511-Aug-03 0:20
eggie511-Aug-03 0:20 
GeneralRe: Which button was pressed... Pin
Heath Stewart11-Aug-03 2:48
protectorHeath Stewart11-Aug-03 2:48 
GeneralRe: Which button was pressed... Pin
eggie511-Aug-03 10:31
eggie511-Aug-03 10:31 
GeneralRe: Which button was pressed... Pin
Csharp™11-Aug-03 0:01
Csharp™11-Aug-03 0:01 

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.