A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a C# Sharp program to convert an integer to string and a string to an integer
Q:

Write a C# Sharp program to convert an integer to string and a string to an integer

0

Write a C# Sharp program to convert an integer to string and a string to an integer

Sample Output:

Original value and type: 50,  System.String
Convert string to integer:
Return value and type: 50,  System.Int32

Original value and type: 122,  System.Int32
Convert integer to string:
Return value and type: 122,  System.String

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
namespace exercises
{
    class Program
    {
        static void Main(string[] args)
        {
            string n_str = "50";            
            Console.WriteLine("Original value and type: " + n_str + ",  " + n_str.GetType());
            int result = test_str_to_int(n_str);
            Console.WriteLine("Convert string to integer:");
            Console.WriteLine("Return value and type: "+ result+",  "+result.GetType());
            int n = 122;
            Console.WriteLine("\nOriginal value and type: " + n + ",  " + n.GetType());
            string result1 = test_int_to_str(n);
            Console.WriteLine("Convert integer to string:");
            Console.WriteLine("Return value and type: " + result1 + ",  " + result1.GetType());
        }
        public static int test_str_to_int(string str)
        {
            return int.Parse(str);
        }

        public static string test_int_to_str(int n)
        {
            return n.ToString();
        }
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now