Blazor:使用@variable在页面上打印值时,可以添加千位分隔符吗?

时间:2019-11-22 05:40:02

标签: c# blazor blazor-client-side

例如,在这样的代码中,

bool FileIO::ReadTextFile(const std::string &FileName, std::string &Contents) {
  bool Result = false;
  std::ifstream FileObj;

  try {
    FileObj.exceptions(std::ifstream::badbit | std::ifstream::failbit);
    if (DoesFileExist(FileName)) {
      FileObj.open(FileName, std::ifstream::in);
      std::stringstream FileContents;
      FileContents << FileObj.rdbuf();
      Contents = FileContents.str();

      Result = true;
    }
  } catch (std::exception &e) {
    std::cout << "Error when reading from file : " << FileName << " "
              << std::strerror(errno) << " Exception : " << e.what()
              << std::endl;
  }

我可以打印“ 1,234,567,890”之类的值吗?

1 个答案:

答案 0 :(得分:2)

尝试一下

<button @onclick="Demo">Click</button>
<span>@stringSize</span>

@code {

    long  size = 1234567890;
    string stringSize = "";

    private void Demo()
    { 
        stringSize = (size).ToString("#,##0.00");
    }

}