== Why is this an issue?

Invoking a method designed to return a string representation of an object which is already a string is a waste of keystrokes. Similarly, explicitly invoking ``++ToString()++`` when the compiler would do it implicitly is also needless code-bloat.


This rule raises an issue when ``++ToString()++`` is invoked:

* on a ``++string++``
* on a non-``++string++`` operand to concatenation
* on an argument to ``++string.Format++``

=== Noncompliant code example

[source,csharp]
----
var s = "foo";
var t = "fee fie foe " + s.ToString();  // Noncompliant
var someObject = new object();
var u = "" + someObject.ToString(); // Noncompliant
var v = string.Format("{0}", someObject.ToString()); // Noncompliant
----

=== Compliant solution

[source,csharp]
----
var s = "foo";
var t = "fee fie foe " + s;
var someObject = new object();
var u = "" + someObject;
var v = string.Format("{0}", someObject);
----

=== Exceptions

The rule does not report on value types, where leaving off the ``++ToString()++`` call would result in automatic boxing.

[source,csharp]
----
var v = string.Format("{0}", 1.ToString());
----

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

* There's no need to call "ToString()" on a string.
* There's no need to call "ToString()", the compiler will do it for you.


'''
== Comments And Links
(visible only on this page)

=== on 11 Dec 2015, 09:11:10 Tamas Vajk wrote:
\[~ann.campbell.2] LGTM

=== on 15 Jan 2016, 14:22:14 Ann Campbell wrote:
\[~dinesh.bolkensteyn] the title you changed was carefully negotiated with [~tamas.vajk]

include::../comments-and-links.adoc[]

endif::env-github,rspecator-view[]
