Click here to Skip to main content
12,290,522 members (30,421 online)
Rate this:
 
Please Sign up or sign in to 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 20-Nov-12 6:36am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Use the System.Media.SoundPlayer class[^]:
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.
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160518.1 | Last Updated 20 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100