Skip to content
lucjon edited this page Sep 14, 2010 · 3 revisions

This is a simple demo. It prompts for a question ID, and prints the body text and the number of answers:

lucas@ubuntu:~/projects/py-stackexchange$ demo/question.py 
Enter a question ID: 4
--- When setting a form's opacity should I use a decimal or double? ---
<p>I'm new to C#, and I want to use a track-bar to change a form's opacity.</p>

<p>This is my code:</p>

<pre><code>decimal trans = trackBar1.Value / 5000
this.Opacity = trans
</code>&lt;/pre>

<p>When I try to build it, I get this error:</p>

<blockquote>
  <p>Cannot implicitly convert type 'decimal' to 'double'</p>
</blockquote>

<p>I tried making <code>trans</code> a double, but then the control doesn't work. This code worked fine for me in VB.NET. </p>

<p>What do I need to do differently?</p>


12 answers.

Sorry, the &lt; there is my fault.