How to replace string.empty to “0”

后端 未结 10 1882
无人共我
无人共我 2021-01-27 11:15

Just like the title says.

I\'ve tried doing str.Replace(\"\",\"0\"); but it gave me error because oldValue has zero length.

Is it possi

10条回答
  •  自闭症患者
    2021-01-27 12:04

    Try This...

    public string Method1()
    {
          string retString = string.Empty;
          //Do Something
          return string.IsNullOrEmpty(retString)?"0":retString;
    }
    

提交回复
热议问题