string.Format("{0,-30}{l:h:m:s}", p.ProcessName,p.StartTime)为什么报错?

来源:百度知道 编辑:UC知道 时间:2024/06/05 00:32:38
如题
string.Format("{0,-30}{l:h:m:s}", p.ProcessName,p.StartTime)报错说格式不对
似乎是时间格式不对
恳请各位高人指点迷津

不是这样用滴~
按照你的要求
string.Format("{0} - {1}",p.ProcessName,p.StartTime.ToString("l:h:m:s"));

显示出来的结果是
Explorerl11:36:25

你把“h”改成大些“H”试试

// This code example demonstrates the String.Format() method.
// Formatting for this example uses the "en-US" culture.

using System;
class Sample
{
enum Color {Yellow = 1, Blue, Green};
static DateTime thisDate = DateTime.Now;

public static void Main()
{
// Store the output of the String.Format method in a string.
string s = "";

Console.Clear();

// Format a negative integer or floating-point number in various ways.
Console.WriteLine("Standard Numeric Format Specifiers");
s = String.Format(
"(C) Currency: . . . . . . . . {0:C}\n" +
"(D) Decimal:. . . . . . . . . {0:D}\n" +
&quo