1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| public static void CreateUInt16DataFile(string dataFileName, Int32 lenght)
{
System.Random aleatoire = new Random();
if (lenght < Int32.MaxValue / 2)
{
UInt16[] valeur = new UInt16[lenght];
byte[] chiffre = new byte[lenght];
Int32 i;
for (i = 0; i < lenght; i++)
{
valeur[i] = Convert.ToUInt16(aleatoire.Next(UInt16.MaxValue));
}
/* foreach (UInt16 s in valeur)
{
chiffre[s]= BitConverter.GetBytes(UInt16)(s);
}*/
File.WriteAllBytes(dataFileName, chiffre);
}
else
{
Console.WriteLine("Impossible! Donner un autre chiffre!");
}
Console.ReadKey(); |