xxxxxxxxxx
// Example 1
double transperancy = trackBar1.Value/5000;
this.Opacity = decimal.ToDouble(transperancy);
// Example 2 - with inline temp
this.Opacity = decimal.ToDouble(trackBar1.Value/5000);
use the decimal type's constructor that takes a double value as an argument.
xxxxxxxxxx
double doubleValue = 3.14159;
decimal decimalValue = new decimal(doubleValue);
the doubleValue variable is converted to a decimal and stored in the decimalValue variable.
Note that converting from double to decimal can result in a loss of precision, as double can represent a wider range of values than decimal.