Click here to Skip to main content
15,914,165 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetCursorPosition(0, 0);
            string str;
            StreamReader f = File.OpenText("c:\\Ourscreen.txt");
            do
            {
                str = Convert.ToString(f.ReadLine());
                Console.WriteLine(str);
            } while (!f.EndOfStream);
            f.Close();




            int ran1, ran2;
            char[] setnames = new char[8] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };

            Random random = new Random();
            int m = 2;
            int[,] sets = new int[8, 8];
            for (int i = 0; i <8; i++)
            {

                Console.SetCursorPosition(27, m);
                m++;
                Console.Write(setnames[i]+"={");

                ran2 = random.Next(4, 9);




                for (int j = 0; j < ran2; j++)
                {

                    ran1 = random.Next(1, 21);

                    for (int k = 0; k < sets.GetLength(1); k++)
                    {
                        if (sets[i,k] == ran1)
                        {
                            ran1 = random.Next(1, 21);
                            k = 0;
                        }

                    }

                        sets[i,j] = ran1;



                        if (j == ran2 - 1)
                            Console.Write(sets[i,j]);
                        else
                        {


                            Console.Write(sets[i,j] + ",");
                        }



                }
                Console.Write("}");
                Console.WriteLine();





            }

            Console.ReadLine();
        }
    }
}
Posted

1 solution

Use the System.Media.SoundPlayer class[^]:
C#
System.Media.SoundPlayer soundPlayer = new System.Media.SoundPlayer();
           soundPlayer.SoundLocation = "sound.wav";
           soundPlayer.Play(); // to play the sound in a loop, call soundPlayer.PlayLooping();

Warning: this will only work for .wav files.
Hope this helps.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Nov-12 14:51pm    
Right, a 5.
--SA
marchest_21 20-Nov-12 14:53pm    
thank you so much

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