border
Fast Splash Screen in English Fast Splash Screen po Slovensky
Main page | C# section | VB6 section | PHP section | MySQL section | Supremus.sk



How to convert String to Int in C#

( 'System.Convert.ToInt32()' vs. 'Int32.Parse()' )

We have two ways how to convert string to int.

We can use 'System.Convert.ToInt32()'
Source code:
    string strMyString = "56";
    int intMyInt = System.Convert.ToInt32(strMyString);

This will return zero value if 'strMyString = null'


The second way is to use 'Int32.Parse()'
Source code:
    string strMyString = "56";
    int intMyInt = Int32.Parse(strMyString);

But this will throw exception if 'strMyString = null' !!!


Comments

There are no comments for this article.

Add your comment, and be first.


Add your comment
User language:

Name:

Subject:





Human verification:
Number 108 is

separator

List of articles

How to compare two Strings in C#
SharpDevelop - how to change 'File version'
How to delete file in C#
How to convert String to Int in C#
How to use Hexadecimal numbers in C#
How to convert Hex number to Int in C#

Smart utilities


Webdesign (c) 2009 - 2018 Supremus.sk
border