Click here to Skip to main content
15,883,889 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to generate random float numbers ranging 0.0 to 1.5
and to store it inside a variable

the values should store inside the variable under certain condition like
in What have you tried? section


apology for my poor explanation i tried my level best


if anybody could explantion this logic it'll be very much helpful to me

What I have tried:

C#
if (x>0)
{
-----
----
random number  should store here like some fldrndmvrble
}
else
{
fldrndmvrble =0;
}

then i want to store the variable here like


C#
var Finalop = fldrndmvrble
Posted
Updated 18-Oct-22 17:50pm
v2

Finally found it

var result= "0";
                        if(Desired condition>0)
                        {
                            Random random = new Random();

                            double val = (random.NextDouble() * (max - min) + min);
                            result= val.ToString("0.##");
                        }

                        var myvar = result; 
 
Share this answer
 
v4
 
Share this answer
 
Comments
Manojkumar-dll 18-Oct-22 23:49pm    
Thank you Sir!!! I figured it out

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900