473,385 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

string to integer conversion

i want to convert the content of label from string to set of integers
Mar 26 '10 #1
6 2856
Bassem
344 100+
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.Split( string [ ] ).


Thanks,
Bassem
Mar 26 '10 #2
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
Mar 28 '10 #3
tlhintoq
3,525 Expert 2GB
Please don't double-post your questions. It divides attempts to help you in an organized and cohesive manner. Your threads have been merged
Mar 28 '10 #4
tlhintoq
3,525 Expert 2GB
Bassem already told you how to convert a string to an int. Why did you start a second thread on this?

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
I love that you are trying to jump in with both feet. And I certainly don't want to discourage. But to be frank, if you can't construct a simple 3 line "if... else" construct then you really don't need to be worrying about neural networking for another few years.

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.
Mar 28 '10 #5
Samishii23
246 100+
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.
Mar 28 '10 #6
tlhintoq
3,525 Expert 2GB
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:
http://www.lmgtfy.com/?q=MSDN+textbo...UTF-8&oe=UTF-8

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
The OP feels that he needs to *convert* the contents of the label from a string to an int. It almost sounds as if (s)he is unaware that a label has .text property... or that there will be no actual *conversion* of the label's text but rather the need to use the .text in the decision making process to then set an int variable to either 1 or 0.

Sure we could just give him/her the one line required:
Expand|Select|Wrap|Line Numbers
  1. int MaleFemale = Textbox1.text.ToLower() == "male" ? 1 : 0 ;
or even a more familiar form:
Expand|Select|Wrap|Line Numbers
  1. int MaleFemale = 0; // set to female unless changed
  2. if Textbox1.text.ToLower() == "male" MailFemale = 1;
But let's be honest with him/her and ourselves. The OP needs to learn the basics of C# - and do some simple exercises and walk before trying to run. If he cannot be bothered with that much, then we do him a disservice by answering the most basic of questions such as this. Because then we become a crutch to lean on. Why learn the language when someone else will answer every little question?
How do I add two ints together?
How do programmatically 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:
If 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?
Mar 29 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: ken | last post by:
I've been looking for a solution to a string to long conversion problem that I've run into >>> x = 'e10ea210' >>> print x e10ea210 >>> y=long(x) Traceback (most recent call last): File...
4
by: - Steve - | last post by:
I have an array of char values that I need to assign to a integer variable. I tried casting it: integer = (int)charArray; but when I run it I get incorrect results in integer. What is the correct...
2
by: Thomas Matthews | last post by:
Hi, I'm working with Borland C++ Builder 6.2. My project uses the std::string class. However, Borland in its infinite wisdom has its own string class, AnsiString. To make my life easier, I...
4
by: Dennis Myrén | last post by:
Hi. Is there a way to utilize the great primitive data type formatting routines available in .NET without working with strings? I want a byte directly rather than a string. I think it is...
9
by: rsine | last post by:
I have developed a program that sends a command through the serial port to our business system and then reads from the buffer looking for a number. Everything worked great on my WinXP system, but...
5
by: Ian Rutherford | last post by:
Heya guys, It seems VB .net no longer supports the awesome ability of VB 6 to declare something as a string and specify how long the string would be all in one line: Public myString as String *...
11
by: Zordiac | last post by:
How do I dynamically populate a string array? I hope there is something obvious that I'm missing here Option Strict On dim s() as string dim sTmp as string = "test" dim i as integer ...
6
by: tommaso.gastaldi | last post by:
Hi, does anybody know a speedy analog of IsNumeric() to check for strings/chars. I would like to check if an Object can be treated as a string before using a Cstr(), clearly avoiding the time...
12
by: Pascal | last post by:
hello and soory for my english here is the query :"how to split a string in a random way" I try my first shot in vb 2005 express and would like to split a number in several pieces in a random way...
7
by: elliotng.ee | last post by:
I have a text file that contains a header 32-bit binary. For example, the text file could be: %%This is the input text %%test.txt Date: Tue Dec 26 14:03:35 2006...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.