![]() | ToStringBuilder Class |
Namespace: Capgemini.CommonObjectUtils
The ToStringBuilder type exposes the following members.
Name | Description | |
---|---|---|
![]() | ToStringBuilder |
Initializes a new instance of the ToStringBuilder class.
|
Name | Description | |
---|---|---|
![]() | AppendT |
Append a field to the string representation.
|
![]() | AppendBase |
Append a base class string representation.
|
![]() | AppendManyT |
Append an enumerable field to the string representation.
|
![]() | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString |
Gets the built string representation.
(Overrides ObjectToString.) |
Strings built by this class start with the subject object's (short) class name. If fields are appended, the class name will be followed by an square bracket delimited list of the fields. Each field will be represented by its name followed by an equals sign and then its value. The text "null" follows the equals sign if a field is null. A brace delimited list of values follows the equals sign if a field is a collection.
This class allows you to append fields to the string in a fluent style.
This is a partial port of the Apache commons ToStringBuilder class.
class Foo { private int field1 = "bar"; private int[] field2 = new int[]{1, 2}; ... public override string ToString() { return new ToStringBuilder(this) .Append("field1", field1) .AppendMany("field2", field2) .ToString(); } }
Foo[field1=bar, field2={1, 2}]