C#教程
C#控制语句
C#函数
C#数组
C#面向对象
C#命名空间和异常
C#文件IO
C#集合
C#多线程
C#其它

C# String Format()

C# String Format()

C# Format() 方法用于将指定字符串中的一个或多个格式项替换为指定对象的字符串表示形式。 p>

签名

public static string Format (String first, Object second) 
public static string Format(IFormatProvider, String, Object)
public static string Format(IFormatProvider, String, Object, Object)
public static string Format(IFormatProvider, String, Object, Object, Object)  
public static string Format(IFormatProvider, String, Object[]) 
public static string Format(String, Object, Object)
public static string Format(String, Object, Object, Object)
public static string Format(String, params Object[])

参数

第一: 它是一个字符串类型的参数。
第二: 它是对象类型参数。

返回

它返回一个格式化的字符串。

C# String Format() 方法示例

    using System;  
    public class StringExample  
    {  
        public static void Main(string[] args)  
        {  
                     
          string s1 = string.Format("{0:D}", DateTime.Now);
          Console.WriteLine(s1);
        }  
    }  
输出:
Saturday, December 17, 2016
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4