Kranarna
asked on
Create a random number
How do I create a random number in visual studio .net 2005 using managed code?
ASKER
what do you have to include to use the random class, because I cant use?
Random class belongs to System namespace, it can be used in any C++/CLI application without additional references.
using namespace System;
...
Random^ r = gcnew Random( 10);
...
using namespace System;
...
Random^ r = gcnew Random( 10);
...
ASKER
This is how my code looks and it doesnt work. Any ideas?
#include <windows.h>
#include <cassert>
#include <cstdio>
int APIENTRY WinMain(
HINSTANCE instance,
HINSTANCE previousInstance,
LPSTR commandLine,
int commandShow)
{
Random^ r = gcnew Random( 10);
}
#include <windows.h>
#include <cassert>
#include <cstdio>
int APIENTRY WinMain(
HINSTANCE instance,
HINSTANCE previousInstance,
LPSTR commandLine,
int commandShow)
{
Random^ r = gcnew Random( 10);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry, thought it was managed, well well.
Thank you!
Thank you!
VC++ 8.0 allows to create both managed and unmanaged applications. In Application Wizard, Project Type step, CLI item contains managed applications, all other items (MFC, Win32 ...) are unmanaged applications, like in old VC++ 6.0.
http://msdn2.microsoft.com/en-US/library/system.random.aspx