Click here to Skip to main content
11,479,951 members (59,937 online)
Rate this: bad
good
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 7: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 at 20-Nov-12 14:51pm
   
Right, a 5.
--SA
marchest_21 at 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
0 OriginalGriff 235
1 Sergey Alexandrovich Kryukov 215
2 Richard MacCutchan 100
3 F-ES Sitecore 85
4 DamithSL 65
0 Sergey Alexandrovich Kryukov 7,890
1 OriginalGriff 7,556
2 Sascha Lefèvre 3,064
3 Maciej Los 2,491
4 Richard Deeming 2,335


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 20 Nov 2012
Copyright © CodeProject, 1999-2015
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