本文整理汇总了C#中TimeOfDay.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TimeOfDay.ToString方法的具体用法?C# TimeOfDay.ToString怎么用?C# TimeOfDay.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeOfDay
的用法示例。
在下文中一共展示了TimeOfDay.ToString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convertion
public static void Convertion(TimeOfDay time)
{
// 将TimeOfDay转换为string
string time_to_str = time.ToString();
Console.WriteLine(time_to_str);
// 将string转换为TimeOfDay
string str_to_time = "Evening";
TimeOfDay time_type = (TimeOfDay)Enum.Parse(typeof(TimeOfDay), str_to_time, true);
}
示例2: AddHours
protected DateTime AddHours(DateTime datetime, TimeOfDay timeOfDay)
{
switch (timeOfDay)
{
case TimeOfDay.Night:
return datetime.AddHours(3);
case TimeOfDay.Morning:
return datetime.AddHours(9);
case TimeOfDay.Midday:
return datetime.AddHours(15);
case TimeOfDay.Evening:
return datetime.AddHours(21);
}
throw new NotImplementedMethodException(datetime.ToString("dd-MMM-yyyy"), timeOfDay.ToString());
}
示例3: BuildString
private static string BuildString(Date modifiedDate, TimeOfDay modifiedTime,
Date? nullableModifiedDate, TimeOfDay? nullableModifiedTime)
{
StringBuilder sb = new StringBuilder();
sb.Append("modifiedDate:").Append(modifiedDate).Append(",");
sb.Append("modifiedTime:").Append(modifiedTime).Append(",");
sb.Append("nullableModifiedDate:").Append(nullableModifiedDate == null ? "null" : nullableModifiedDate.ToString()).Append(",");
sb.Append("nullableModifiedTime:").Append(nullableModifiedTime == null ? "null" : nullableModifiedTime.ToString());
return sb.ToString();
}
示例4: ToStringWithISOTimeFormat_s
public void ToStringWithISOTimeFormat_s()
{
var time = new TimeOfDay(23, 59, 59);
var s = time.ToString("s");
Assert.Equal("23:59:59", s);
}
示例5: ToStringWithCustomTimeFormat
public void ToStringWithCustomTimeFormat()
{
var time = new TimeOfDay(23, 59, 59);
var s = time.ToString("HH:mm:ss");
Assert.Equal("23:59:59", s);
}
示例6: ToStringWithNullTimeFormat
public void ToStringWithNullTimeFormat()
{
var time = new TimeOfDay(23, 59, 59);
var s = time.ToString((string) null);
Assert.Equal("23:59:59", s);
}
示例7: ToStringWithStandardTimeFormat
public void ToStringWithStandardTimeFormat()
{
var time = new TimeOfDay(23, 59, 59);
var s = time.ToString("t");
Assert.Equal("23:59", s);
}
示例8: WriteValue
/// <summary>
/// Write a TimeOfDay value
/// </summary>
/// <param name="writer">The text writer to write the output to.</param>
/// <param name="value">TimeOfDay value to be written.</param>
internal static void WriteValue(TextWriter writer, TimeOfDay value)
{
Debug.Assert(writer != null, "writer != null");
WriteQuoted(writer, value.ToString());
}
示例9: ToString
/// <summary>
/// Converts the given TimeOfDay value to the string appropriate for Atom format.
/// </summary>
/// <param name="time">The TimeOfDay value to convert.</param>
/// <returns>The string version of the TimeOfDay in Atom format</returns>
internal static string ToString(TimeOfDay time)
{
return time.ToString();
}
示例10: SetTimeOfDay
private void SetTimeOfDay(TimeOfDay timeOfDay)
{
_timeOfDay = timeOfDay;
btnTimeOfDay.Content = _timeOfDay.ToString();
}
示例11: TimeOfDayAsXml
/// <summary>
/// Converts the TimeOfDay to a String.
/// </summary>
/// <param name="time">The <see cref="Microsoft.OData.Edm.Library.TimeOfDay"/> to be converted</param>
/// <returns>A System.String representation of the supplied <see cref="Microsoft.OData.Edm.Library.TimeOfDay"/>.</returns>
internal static string TimeOfDayAsXml(TimeOfDay time)
{
var value = time.ToString();
return value;
}
示例12: WriteGreeting
public static void WriteGreeting(TimeOfDay timeofDay)
{
switch (timeofDay)
{
case TimeOfDay.Morning:
Console.WriteLine("Good " + timeofDay.ToString());
break;
default:
Console.WriteLine("Hello!");
break;
}
}
示例13: ToStringWithEmptyTimeFormat
public void ToStringWithEmptyTimeFormat()
{
var time = new TimeOfDay(23, 59, 59);
var s = time.ToString("");
Assert.Equal("11:59:59 PM", s);
}