i want to convert the content of label from string to set of integers
string to integer conversion
Collapse
X
-
Tags: None
-
A set of integers?
There is a method to convert a string to many types like integer.
Convert.ToInt32 (Label1.Text) will do that.
But a set of strings, you first need to split the text of the label according to your text. ex: a comma-delimited or space, use Label1.Text.Spl it( string [ ] ).
Thanks,
Bassem -
urgent pls help me with the c# code
i have form contain label this label contents is string and i want to convert it to integer (ex:the label may have male or female i want to put 1 for male and 0 for female using if else)to be used as inputs to neural networkComment
-
Bassem already told you how to convert a string to an int. Why did you start a second thread on this?
Originally posted by 7ayati have form contain label this label contents is string and i want to convert it to integer (ex:the label may have male or female i want to put 1 for male and 0 for female using if else)to be used as inputs to neural network
I would HIGHLY recommend you get a couple books of "Learn C# in 21 days", "My first C# program", "C# for the beginner" etc. You need to work through the basic 'Hello world' applications that we *all* start. You need to learn the C# language before you can write programs that use it. Just as you have to learn the English language before you can expect to write a mystery novel.Comment
-
Heres a tip. Google the MSDN website. Then in the MSDN search, use "Convert X to X". Usually just the simple terminology gives good results. Or search in google the exact question. Google searchs go up to 33 words long. Theres bound to be hundreds of others who have asked and others who have responded.Comment
-
Bassem has already provided the Convert.ToInt code
I have already provided a link to MSDN for how to form an If...else construct.
Personally I don't care for the MSDN search implication through Bing. I find that if I need to search for something on MSDN that google is the better tool. Searching for "MSDN" plus my need usually takes me right to the answer.
"MSDN textbox.text" as in this example:
For all those people who find it more convenient to bother you with their question rather than to Google it for themselves.
While Samishii and I have slightly varying preferences on details of searching, the underlying concept remains the same: Check the MSDN.
In the case of the OP's original need though I suspect that he simply did not know what to search for. If one knows so little of C# as to not know there is an if...else construct for making decisions then what would you search for to solve the original question?
Look at the original question:i have form contain label this label contents is string and i want to convert it to integer (ex:the label may have male or female i want to put 1 for male and 0 for female using if else)to be used as inputs to neural network
Sure we could just give him/her the one line required:
Code:int MaleFemale = Textbox1.text.ToLower() == "male" ? 1 : 0 ;
Code:int MaleFemale = 0; // set to female unless changed if Textbox1.text.ToLower() == "male" MailFemale = 1;
How do I add two ints together?
How do programmaticall y set the text of a label?
How do tell if a checkbox is checked?
It is my own personal opinion and I do not speak for Bytes management when I say:Originally posted by tlhIn'toqIf a person can't be bothered to take upon themselves the most basic of reading, the most basic of tutorials, the most basic of books, the most basic of responsibility for their own education and career path, then why would I be bothered to take their education or the problem more seriously than they themselves do?Comment
Comment