Why does 'true' equal $true
<p>I'm not quite sure if this exact question is a duplicate, but I couldn't find my specific question on stackoverflow, so I guess it's not.</p>

<p><code>$true</code> is a boolean type:</p>

<pre><code>($true).getType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Boolean                                  System.ValueType
</code></pre>

<p><code>'true'</code> is a string:</p>

<pre><code>('true').gettype()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object
</code></pre>

<p>why is this condition true?</p>

<pre><code>PS C:\WINDOWS\system32&gt; if ('True' -eq $true) {'yes'} else {'no'}
yes
</code></pre>

<p>only because the string is called True just like the boolean true? If I compare it with any other string, there is a different outcome:</p>

<pre><code>PS C:\WINDOWS\system32&gt; 'hello' -eq $true
False
PS C:\WINDOWS\system32&gt; 'true' -eq $true
True
</code></pre>

<p>if you do <code>'true' == true</code> in C# it prints an <code>cannot convert string to bool</code> error and both C# and PS are based on .net and have quite the same syntax. why is there a different outcome?
this seems very strange to me.</p>

<p>How is PowerShell evaluating <code>'true'</code> to <code>$true</code>?</p>