Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
QuestionGet current page source from a toolbar Pin
Kirys26-Mar-10 5:09
Kirys26-Mar-10 5:09 
AnswerRe: Get current page source from a toolbar Pin
Kirys29-Mar-10 6:02
Kirys29-Mar-10 6:02 
Questionhow to string to binary Pin
tai-fun26-Mar-10 4:56
tai-fun26-Mar-10 4:56 
AnswerRe: how to string to binary Pin
Richard MacCutchan26-Mar-10 5:00
mveRichard MacCutchan26-Mar-10 5:00 
AnswerRe: how to string to binary Pin
OriginalGriff26-Mar-10 5:14
mveOriginalGriff26-Mar-10 5:14 
AnswerRe: how to string to binary Pin
tai-fun26-Mar-10 5:17
tai-fun26-Mar-10 5:17 
GeneralRe: how to string to binary Pin
harold aptroot26-Mar-10 5:59
harold aptroot26-Mar-10 5:59 
AnswerRe: how to string to binary Pin
Luc Pattyn26-Mar-10 5:21
sitebuilderLuc Pattyn26-Mar-10 5:21 
Hi,

let me put a couple of things straight first: there are no decimal numbers, no hexadecimal numbers, no binary numbers, there are just numbers. A number is a number, it does not have a base.

It is only when a number gets represented by a string (maybe because it gets shown to the user, or input by the user) that it becomes a decimal, hexadecimal, binary, or whatever representation of that number.

And here are some typical operations:
int num=20;
string decimal1=num.ToString();
string decimal2=num.ToString("D5");
Console.WriteLine("decimal representation: "+decimal1);

string hex4=num.ToString("X4");
Console.WriteLine("hexdecimal representation: "+hex4);
int val16;
int32.TryParse(hex4, NumberStyles.Hexadecimal, null, out val16);
Console.WriteLine("The value of hex "+hex4+" is "+val16);

string binary=Convert.ToString(num, 2);
int val2=Convert.ToInt32(binary, 2);
Console.WriteLine("The value of binary "+binary+" is "+val2);

string octal=Convert.ToString(num, 8);
int val8=Convert.ToInt32(binary, 8);
Console.WriteLine("The value of octal"+octal+" is "+val8);


Smile | :)

GeneralRe: how to string to binary Pin
tai-fun26-Mar-10 5:51
tai-fun26-Mar-10 5:51 
GeneralRe: how to string to binary Pin
Luc Pattyn26-Mar-10 6:04
sitebuilderLuc Pattyn26-Mar-10 6:04 
GeneralRe: how to string to binary Pin
OriginalGriff26-Mar-10 6:00
mveOriginalGriff26-Mar-10 6:00 
GeneralRe: how to string to binary Pin
tai-fun26-Mar-10 6:06
tai-fun26-Mar-10 6:06 
GeneralRe: how to string to binary Pin
Luc Pattyn26-Mar-10 6:32
sitebuilderLuc Pattyn26-Mar-10 6:32 
GeneralRe: how to string to binary Pin
Luc Pattyn26-Mar-10 6:36
sitebuilderLuc Pattyn26-Mar-10 6:36 
GeneralRe: how to string to binary Pin
OriginalGriff26-Mar-10 6:48
mveOriginalGriff26-Mar-10 6:48 
GeneralRe: how to string to binary Pin
Luc Pattyn26-Mar-10 6:56
sitebuilderLuc Pattyn26-Mar-10 6:56 
GeneralRe: how to string to binary Pin
OriginalGriff26-Mar-10 11:20
mveOriginalGriff26-Mar-10 11:20 
GeneralRe: how to string to binary Pin
Luc Pattyn26-Mar-10 11:25
sitebuilderLuc Pattyn26-Mar-10 11:25 
GeneralRe: how to string to binary Pin
OriginalGriff26-Mar-10 22:25
mveOriginalGriff26-Mar-10 22:25 
GeneralRe: how to string to binary Pin
T M Gray26-Mar-10 11:51
T M Gray26-Mar-10 11:51 
GeneralRe: how to string to binary Pin
Luc Pattyn26-Mar-10 12:00
sitebuilderLuc Pattyn26-Mar-10 12:00 
AnswerRe: how to string to binary Pin
tai-fun26-Mar-10 6:37
tai-fun26-Mar-10 6:37 
AnswerRe: how to string to binary Pin
DaveyM6926-Mar-10 6:49
professionalDaveyM6926-Mar-10 6:49 
QuestionNot able to assign the picture to toolbar item. Pin
SRKSHOME26-Mar-10 2:16
SRKSHOME26-Mar-10 2:16 
AnswerRe: Not able to assign the picture to toolbar item. Pin
Ravi Bhavnani26-Mar-10 2:57
professionalRavi Bhavnani26-Mar-10 2:57 

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.