本文整理汇总了C#中System.Object.?.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Object.?.ToString方法的具体用法?C# Object.?.ToString怎么用?C# Object.?.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Object
的用法示例。
在下文中一共展示了Object.?.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertValue
/// <summary>
/// Converts a value to the specified type.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <param name="originalType">The value's original type.</param>
/// <param name="conversionType">The type to which to convert the value.</param>
/// <param name="formatString">The format string used to convert objects to strings.</param>
/// <param name="coerceToString">A value indicating whether to coerce Object values to String values if no valid type conversion exists.</param>
/// <returns>The converted value.</returns>
public static Object ConvertValue(Object value, Type originalType, Type conversionType, String formatString, Boolean coerceToString)
{
if (IsStringType(conversionType, coerceToString))
{
var stringValue = ConvertUsingToString(value, originalType, formatString);
return (conversionType == typeof(VersionedStringSource)) ?
new VersionedStringSource((String)stringValue) : stringValue;
}
if (conversionType == typeof(StringBuilder))
return new StringBuilder(value?.ToString());
if (conversionType == typeof(VersionedStringBuilder))
return new VersionedStringBuilder(value?.ToString());
return ConvertUsingTypeConverter(value, originalType, conversionType);
}
示例2: example2
private Boolean example2(Object value)
{
var value2 = value != null ? value.ToString() : null;
var value3 = value?.ToString();
return value2 == value3;
}
示例3: CollectUnknownMimeTypes
// Works in old debugger (managed compatibility mode) only
public static Boolean CollectUnknownMimeTypes(Object c, Object value)
{
((ICollection<String>)c).Add(value?.ToString());
return true;
}