C# 是否有一个格式表达式可用于在字符串中插入小数点?

C# 是否有一个格式表达式可用于在字符串中插入小数点?,c#,asp.net,C#,Asp.net,我有一个中继器,其中包括ICD9代码作为一个值: <asp:Repeater runat="server" ID="rptDRGGrouper"> <HeaderTemplate> <table> <tr> <th>ICD9 Code</th> <th>Description</th>

我有一个中继器,其中包括ICD9代码作为一个值:

<asp:Repeater runat="server" ID="rptDRGGrouper">
       <HeaderTemplate>
           <table>
           <tr>
              <th>ICD9 Code</th>
              <th>Description</th>
          </tr>
      </HeaderTemplate>
      <ItemTemplate>
         <tr>
             <td><%#DataBinder.Eval(Container.DataItem, "ICD9Code").ToString()%></td>
             <td><%#DataBinder.Eval(Container.DataItem, "Description").ToString()%></td>
         </tr>
     </ItemTemplate>
     <FooterTemplate>
        </table>
    </FooterTemplate>
</asp:Repeater>
第三个字符(如果有第四个字符)后应加一个小数。e、 g


从表面上看,我将为此创建一个扩展方法:

public static class Extensions
{
    public static string ICD9Format(this string input)
    {
        //check easy cases first
        if (string.IsNullOrEmpty(input) || input.Length <= 3)
        {
            return input;
        }

        return input.Insert(3, ".");
    }
}
公共静态类扩展
{
公共静态字符串ICD9Format(此字符串输入)
{
//先检查简单的案例

如果(string.IsNullOrEmpty(input)| | input.Length取面值,我将为此创建一个扩展方法:

public static class Extensions
{
    public static string ICD9Format(this string input)
    {
        //check easy cases first
        if (string.IsNullOrEmpty(input) || input.Length <= 3)
        {
            return input;
        }

        return input.Insert(3, ".");
    }
}
公共静态类扩展
{
公共静态字符串ICD9Format(此字符串输入)
{
//先检查简单的案例

如果(string.IsNullOrEmpty(input)| | input.Length,请确保将扩展类导入到您的aspx页面,使其可用。必须确保将扩展类导入到您的aspx页面,使其可用
public static class Extensions
{
    public static string ICD9Format(this string input)
    {
        //check easy cases first
        if (string.IsNullOrEmpty(input) || input.Length <= 3)
        {
            return input;
        }

        return input.Insert(3, ".");
    }
}
<td>
<%#DataBinder.Eval(Container.DataItem, "ICD9Code").ToString().ICD9Format()%>
</td>