How to convert int to string, int to double, string to int in C# or C sharp?

All QuestionsCategory: C#_languageHow to convert int to string, int to double, string to int in C# or C sharp?
Chetan Shidling asked 4 years ago

I need short information.

1 Answers
Chetan Shidling answered 4 years ago

I will share one code
 

using System;

namespace MyApplication
{
  class Program
  {
    static void Main(string[] args)
    {
      int myInt = 23;
      double myDouble = 25.25;
      bool myBool = false;

      Console.WriteLine(Convert.ToString(myInt));    // Convert int to string
      Console.WriteLine(Convert.ToDouble(myInt));    // Convert int to double
      Console.WriteLine(Convert.ToInt32(myDouble));  // Convert double to int
      Console.WriteLine(Convert.ToString(myBool));   // Convert bool to string
      }
  }
}