Inserting an integer value in a TextBox

后端 未结 5 1662
臣服心动
臣服心动 2020-12-07 05:37

I need to show an integer value in a TextBox in my C# Windows Forms application (GUI). I have an int32 value available. I could not find a container like a TextBox that take

相关标签:
5条回答
  • 2020-12-07 05:40
    int i = 10;
    TextBox1.Text = i.ToString();
    
    0 讨论(0)
  • 2020-12-07 05:47

    You can do this in many ways:

            int i = 123893232;
            Console.WriteLine(i.ToString());//123893232
            Console.WriteLine(Convert.ToString(i));//123893232
            Console.WriteLine(String.Format("{0:C}", i));//123 893 232,00 zł(Polish)
            Console.WriteLine(String.Format("{0:D}", i));//123893232
            Console.WriteLine(String.Format("{0:E}", i));//1,238932E+008
            Console.WriteLine(String.Format("{0:F}", i));//123893232,00
            Console.WriteLine(String.Format("{0:G}", i));//123893232
            Console.WriteLine(String.Format("{0:N}", i));//123 893 232,00
            Console.WriteLine(String.Format("{0:P}", i));//12 389 323 200,00
            Console.WriteLine(String.Format("{0:X}", i));//76275F0 
    
    0 讨论(0)
  • 2020-12-07 05:50

    TextBox.Text = MyInteger.ToString();

    0 讨论(0)
  • 2020-12-07 05:56

    Everything in .NET can be transformed to a string in one way or another by using the "ToString()" method.

    Example

    int x = 5;
    string y = x.ToString();
    
    0 讨论(0)
  • 2020-12-07 05:59

    You can use the ToString() method to convert the integer to a string.

    int x = 10;

    Console.WriteLine(x.ToString())

    0 讨论(0)
提交回复
热议问题