Textbox display formatting

前端 未结 5 1357
花落未央
花落未央 2020-12-19 21:30

I want to add \",\" to after every group of 3 digits. Eg : when I type 3000000 the textbox will display 3,000,000 but the value still is 3000000.
I tried to use maskedte

5条回答
  •  心在旅途
    2020-12-19 21:57

    Use String.Format

    int value = 300000
    String.Format("{0:#,###0}", value);
    // will return 300,000
    

    http://msdn.microsoft.com/en-us/library/system.string.format.aspx

提交回复
热议问题