本文整理汇总了C#中System.Object.toString方法的典型用法代码示例。如果您正苦于以下问题:C# Object.toString方法的具体用法?C# Object.toString怎么用?C# Object.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Object
的用法示例。
在下文中一共展示了Object.toString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: valueOf
/**
* Converts the specified object to its string representation. If the object
* is null return the string {@code "null"}, otherwise use {@code
* toString()} to get the string representation.
*
* @param value
* the object.
* @return the object converted to a string, or the string {@code "null"}.
*/
public static String valueOf(Object value)
{
return value != null ? value.toString() : "null"; //$NON-NLS-1$
}
示例2: insert
/**
* Inserts the string representation of the specified {@code Object} at the
* specified {@code offset}. The {@code Object} value is converted to a
* String according to the rule defined by {@link String#valueOf(Object)}.
*
* @param offset
* the index to insert at.
* @param obj
* the {@code Object} to insert.
* @return this builder.
* @throws StringIndexOutOfBoundsException
* if {@code offset} is negative or greater than the current
* {@code length()}.
* @see String#valueOf(Object)
*/
public StringBuilder insert(int offset, Object obj)
{
insert0(offset, obj == null ? "null" : obj.toString()); //$NON-NLS-1$
return this;
}
示例3: append
/**
* Appends the string representation of the specified {@code Object}.
* The {@code Object} value is converted to a string according to the rule
* defined by {@link String#valueOf(Object)}.
*
* @param obj
* the {@code Object} to append.
* @return this builder.
* @see String#valueOf(Object)
*/
public StringBuilder append(Object obj)
{
if (obj == null) {
appendNull();
} else {
append0(obj.toString());
}
return this;
}
示例4: append
/**
* Adds the string representation of the specified object to the end of this
* StringBuffer.
* <p />
* If the specified object is {@code null} the string {@code "null"} is
* appended, otherwise the objects {@code toString} is used to get its
* string representation.
*
* @param obj
* the object to append (may be null).
* @return this StringBuffer.
* @see String#valueOf(Object)
*/
public java.lang.StringBuffer append(Object obj)
{
lock (this) {
if (obj == null) {
appendNull();
} else {
append0(obj.toString());
}
return this;
}
}
示例5: convertKey
//-----------------------------------------------------------------------
/**
* Overrides convertKey() from {@link AbstractHashedMap} to convert keys to
* lower case.
* <p>
* Returns null if key is null.
*
* @param key the key convert
* @return the converted key
*/
protected override Object convertKey(Object key)
{
if (key != null)
{
return key.toString().ToLower();
}
else
{
return AbstractHashedMap.NULL;
}
}
示例6: checkNotNullAndLog
protected static void checkNotNullAndLog(String argName, Object value) {
Preconditions.checkArgument(value != null && !value.toString().isEmpty(),
argName + " is null or empty");
log.debug("{}: {}", argName, value);
}