Click here to Skip to main content
15,897,187 members
Home / Discussions / C#
   

C#

 
QuestionData Transfer Pin
Le Hoang Viet22-Jul-07 18:34
Le Hoang Viet22-Jul-07 18:34 
AnswerRe: Data Transfer Pin
Christian Graus22-Jul-07 18:48
protectorChristian Graus22-Jul-07 18:48 
QuestionWebcam Server Pin
Le Hoang Viet22-Jul-07 15:51
Le Hoang Viet22-Jul-07 15:51 
AnswerRe: Webcam Server Pin
Christian Graus22-Jul-07 17:04
protectorChristian Graus22-Jul-07 17:04 
QuestionBinary into ASCII Pin
ScIeNcE_ErRoR22-Jul-07 15:01
ScIeNcE_ErRoR22-Jul-07 15:01 
AnswerRe: Binary into ASCII Pin
Luc Pattyn22-Jul-07 15:24
sitebuilderLuc Pattyn22-Jul-07 15:24 
GeneralRe: Binary into ASCII Pin
ScIeNcE_ErRoR22-Jul-07 16:05
ScIeNcE_ErRoR22-Jul-07 16:05 
GeneralRe: Binary into ASCII Pin
Luc Pattyn22-Jul-07 17:23
sitebuilderLuc Pattyn22-Jul-07 17:23 
OK, I misunderstood you; what you want is conversions between numbers and their
string representations (e.g. between 123 and "123").

Here it goes:

int intValue=123;
string strDecimal=intValue.ToString();     // yields "123"
string strHex=intValue.ToString("X2");     // yields "7B"
string strHey=intValue.ToString("X4");     // yields "007B"


For more, read up on the ToString() method of the base types (int, byte, double, ...);
you may have to look for Int32 instead of int though.

The reverse is called "parsing", i.e. try to figure out if the string contains a
valid int, byte, double, whatever. Since .NET 2.0 they have two variants:
TryParse() will return a bool to indicate success
Parse() will return a value, and throw an Exception on failure

some examples:

string str="12345";
int myDecimal=int.Parse(str);      // yields the number 12345
byte overfl=byte.Parse(str);       // throws some overflow exception
int myHex=int.Parse(str,NumberStyles.AllowHexSpecifier);  // yields integer 74565 (was hex !)
    // and yes the AllowHexSpecifier is a misnomer


and there are many more.

Sorry about the confusion, but its not ASCII, everything in this message occurs
in memory, hence in Unicode; and the ints and bytes get their value (which happens
to be stored in binary but that is not relevant most of the time).



GeneralRe: Binary into ASCII Pin
ScIeNcE_ErRoR23-Jul-07 13:51
ScIeNcE_ErRoR23-Jul-07 13:51 
GeneralRe: Binary into ASCII Pin
Luc Pattyn23-Jul-07 14:17
sitebuilderLuc Pattyn23-Jul-07 14:17 
QuestionPowerPoint Pin
half-life22-Jul-07 13:25
half-life22-Jul-07 13:25 
AnswerRe: PowerPoint Pin
Paul Conrad22-Jul-07 15:53
professionalPaul Conrad22-Jul-07 15:53 
AnswerRe: PowerPoint Pin
Luc Pattyn22-Jul-07 17:33
sitebuilderLuc Pattyn22-Jul-07 17:33 
GeneralRe: PowerPoint Pin
Paul Conrad22-Jul-07 18:26
professionalPaul Conrad22-Jul-07 18:26 
GeneralRe: PowerPoint Pin
Luc Pattyn23-Jul-07 1:18
sitebuilderLuc Pattyn23-Jul-07 1:18 
GeneralRe: PowerPoint Pin
Paul Conrad23-Jul-07 5:59
professionalPaul Conrad23-Jul-07 5:59 
QuestionFind a Button with HitTest Pin
donovan.solms22-Jul-07 12:00
donovan.solms22-Jul-07 12:00 
AnswerRe: Find a Button with HitTest Pin
Luc Pattyn22-Jul-07 12:24
sitebuilderLuc Pattyn22-Jul-07 12:24 
GeneralRe: Find a Button with HitTest Pin
donovan.solms22-Jul-07 13:10
donovan.solms22-Jul-07 13:10 
GeneralRe: Find a Button with HitTest Pin
Luc Pattyn22-Jul-07 13:44
sitebuilderLuc Pattyn22-Jul-07 13:44 
QuestionThe Location of the cursor in a Text Box Pin
max2929722-Jul-07 11:23
max2929722-Jul-07 11:23 
AnswerRe: The Location of the cursor in a Text Box Pin
Christian Graus22-Jul-07 11:27
protectorChristian Graus22-Jul-07 11:27 
AnswerRe: The Location of the cursor in a Text Box Pin
mav.northwind22-Jul-07 19:17
mav.northwind22-Jul-07 19:17 
GeneralRe: The Location of the cursor in a Text Box Pin
max2929723-Jul-07 8:01
max2929723-Jul-07 8:01 
Questionplease any one can help me pleeeeeeeeeeeeeeeeease to insert new row into DataGrid Pin
michaelqog22-Jul-07 10:54
michaelqog22-Jul-07 10:54 

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.