ASP.NET / C#

Convert String to Integer

When data is received via a textbox it is a string. If you need to do calculations on this data then you need to convert the string into an integer.

VB.NET

dim intTotal as Integer
dim strPrice as string = "35"
intTotal =  Int32.Parse(strPrice) + 5 

C#

int IntTotal;
string strAge = "35";
intTotal = Convert.ToInt32(strPrice) + 5;

Now the numbers can be added together to equal 40.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s