Prev: looking for the method like postmessage in win32.
Next: LINQ - Picking the most recently created file
From: sahel on 15 Mar 2010 08:56 Hi; I wrote a program that I want to put a number in char (I mean : char s = '8';) 7 than put the number I put that at char s to int ; But it does not work correctly ; I mean it doesnt show 8 ; using System; class Program { static void Main(string[] args) { char s = '8'; int f =s; Console.WriteLine(f); } } thanks . . .
From: Tony Johansson on 15 Mar 2010 09:17 "sahel" <nam.nam.barooon(a)gmail.com> skrev i meddelandet news:3cdd2741-89d0-4c02-a7a4-bfc89efc92bc(a)m37g2000yqf.googlegroups.com... Hi; I wrote a program that I want to put a number in char (I mean : char s = '8';) 7 than put the number I put that at char s to int ; But it does not work correctly ; I mean it doesn't show 8 ; using System; class Program { static void Main(string[] args) { char s = '8'; int f =s; Console.WriteLine(f); } } thanks . . . All writeable characters has a specific representation in ASCII for example the chracter '8' is represented by number 56. When you do int f =s; you say tell me what number character '8' represents and you will have number 56 //Tony
From: Bjørn Brox on 15 Mar 2010 09:18 sahel skrev: > Hi; > I wrote a program that I want to put a number in char (I mean : char > s = '8';) > 7 than put the number I put that at char s to int ; > But it does not work correctly ; > I mean it doesn�t show 8 ; > using System; > class Program > { > static void Main(string[] args) > { > char s = '8'; > int f =s; > Console.WriteLine(f); > } > } > > thanks . . . What makes you think that it should show 8? Time to learn the difference between char and int. -- Bj�rn Brox
From: sahel on 15 Mar 2010 09:30 On Mar 15, 4:17 pm, "Tony Johansson" <johansson.anders...(a)telia.com> wrote: > "sahel" <nam.nam.baro...(a)gmail.com> skrev i meddelandetnews:3cdd2741-89d0-4c02-a7a4-bfc89efc92bc(a)m37g2000yqf.googlegroups.com... > Hi; > I wrote a program that I want to put a number in char (I mean : char > s = '8';) > 7 than put the number I put that at char s to int ; > But it does not work correctly ; > I mean it doesn't show 8 ; > using System; > class Program > { > static void Main(string[] args) > { > char s = '8'; > int f =s; > Console.WriteLine(f); > } > } > > thanks . . . > > All writeable characters has a specific representation in ASCII for example > the chracter '8' is represented by > number 56. When you do > int f =s; > you say tell me what number character '8' represents and you will have > number 56 > > //Tony hi; i want this answer because i want to get some char from user like this : y=(x^2)+1 so i will put 2 in char but to write the program for it that it must do an math question ,program must know that 2 & 1 are not char they are int
From: Konrad Neitzel on 15 Mar 2010 11:38 Hi Sahel! "sahel" <nam.nam.barooon(a)gmail.com> schrieb im Newsbeitrag news:3cdd2741-89d0-4c02-a7a4-bfc89efc92bc(a)m37g2000yqf.googlegroups.com... > Hi; > I wrote a program that I want to put a number in char (I mean : char > s = '8';) > 7 than put the number I put that at char s to int ; > But it does not work correctly ; > I mean it doesn�t show 8 ; > using System; > class Program > { > static void Main(string[] args) > { > char s = '8'; > int f =s; > Console.WriteLine(f); > } > } > > thanks . . . You already got answers that told you a little about the different types. Maybe you simply read more about ascii and UTF(-8/-16/-32). Good sources can be found through google or simply check the wikipedia. The .Net Framework provides functions to get information from one type to another. In case of reading stings (Which are multiple characters), the functions you would like are: Int32.Parse and Int32.TryParse. Just check msdn for a description of these functions (and msdn often has an example that shows the possibilities in a quick way!). Mentioned Links: http://en.wikipedia.org/wiki/Main_Page http://msdn.microsoft.com/en-us/library/default.aspx With kind regards, Konrad
|
Next
|
Last
Pages: 1 2 3 Prev: looking for the method like postmessage in win32. Next: LINQ - Picking the most recently created file |