Random Number Generation - Cerebus mb

Hello TinyCLR community,

I am new to Gadgeteer and to C# programming, my background is in HW and I see the Gadgeteer system as a means to developing my programming skills.

Before I go any further if anyone is beginning to learn C# like myself then have a look at the videos on Channel 9: C# Fundamentals: Development for Absolute Beginners | Microsoft Learn

They were very helpful to me and I hope they help you as well.

I am trying to write a bit of code to generate a random number between 1-100. The first code snippet below works when I generate a standard .cs file however when I am programming within a Gadgeteer template the code does not work (ERROR: No overload for method ‘Next’ takes 2 arguments).
I understand that the .NET Gadgeteer uses the .NET Micro Framework which is a subset of the .NET platforms. I suspect that this is the reason why the code isn’t working, am I right? And can anyone suggest a method to generate a random number using .NET Gadgeteer? I have been scouring the net but the valid solutions are for standard C#.

Thanks in advance to all

Check the parameters for the next function in the MF Random class documentation. Random Class | Microsoft Learn

@ naveej - Mike’s answer is more helpful, but it’s rand.Next(100)

naveej - Welcome!

“I suspect that this is the reason why the code isn’t working, am I right?” – You are correct.

Hello Mike, Justic and mhectorgato!

Apologies for my delay in responding, I was looking at the link that Mike provided to the msdn website. Thanks Mike, you have given me a future reference for any syntax issues I may have.

And thanks Justin, I drilling down to the issue but the solution you gave in conjuction with the example syntax on the msdn website helped me to understand.

And mhectorgato thank you for confirming what the bigger issue was.

I appreciate the assistance that you all provided. Thank you for taking the time to post a response.

Regards to all
naveej