Showing posts with label Int. Show all posts
Showing posts with label Int. Show all posts

Saturday, 1 November 2014

Converting String to Int in C#

String is the reference type in C# and int is the value type.(What is Ref and Value type )
So, The way of maintain the memory location are quite different for both of them and to converting the value to refrence is called boxing in C#.

If you see the below program;
static void Main(string[] args)
        {
            int i = 123;
            string str = "123";

            if (str.Equals(i))
                Console.WriteLine("Success");
            else
                Console.WriteLine("fails");

        }