tags:

views:

269

answers:

10

So, Im a beginning C# programmer. I know basic syntax and simple things like if statements and loops(methods and classes too). I've only used console apps right now havent bothered with windows forms yet.

So any simple app ideas that introduce new things important for C# programming.

Also, NO tutorials. I want to make all by myself.

+3  A: 

A simple game might be a good start but those code golf questions can be a bit more advanced.

Why not try to write a 'test your reflexes' game, where you output a letter and time how long it takes for that letter to be keyed in? Then display the response time taken and the best response time to date.

amelvin
Yeah, I could make a typing game. It times your speed and accuracy..Also I want to spend a little while on just C# before I move on to C#+XNA framework
XNA? I recommend you try SlimDX first, to get a general feel for 3d graphics. You can't just dive straight into video game development [which is the only thing XNA is really good for =/]
ItzWarty
A: 

C# and the dot net frameowrk are all geared towards visual windows based applications. You could go down the web route and create some sort of web application (stack overflow itself is created with asp.net / c# i belive). Windows forms / desktop based wise well i dont think you can go wrong with traditional business apps that have some sort of database behind them - booking systems, scheduling systems etc

C# itself is not the important thing here, its the programming fundamentals: OOP ( classes, inheritance, poly-morphism etc), loops, database access etc - that are important. Focus on these and you can apply them to other languages also - java, ,python, c++ (to some extent) etc etc.

C# is just sytanx.

Drew
I wouldn't say that .NET is geared more towards "visual windows based" applications any more than the other major languages.
tbischel
+1  A: 

Write something recursive, like a routine that calculates the value of a factorial.

Cyberherbalist
+2  A: 

Once i had to learn bash scripting for linux by writing the hangman game, it should be a good example for a console app in c#.

Hint:

start with

while(true)
{
//Game code goes here, use "continue" or "break" according to game logic.
}
Bablo
+1  A: 

One fun way to develop your skills is through code katas and programming contests like Top Coder and Google Code Jam. There are tons of example problems that will make you think, and many come with solutions that you can compare against after you are finished.

Even when you've been a developer for a while, these kind of simple problems allow you to incorporate new practices in your programming style (for instance, a kata is a great way to start learning the principles of TDD). Plus, they make for fun distractions.

tbischel
+1  A: 

I think solving Top-Coder problems will be great practice! It's specially suited since all their problems are console based, and they will make you increase not only your knowledge of c#, but also your problem solving skills and your data structure/algorithms knowledge.

That said, you probably wont learn much about new or more platform specific stuff about C#, such as linq, event handlers, threading, parallel tasks library, etc etc. For that, the best would be to find a good C# book and go through it.

Another way could be making little games. I know its console, but you can actually make games like Snake, Pac-man, hangman, etc, of course, with a little extra imagination, but it still works and games are great learning exercises (and are fun to show to people)

Francisco Noriega
+2  A: 

I'm a big fan of Halo, and one of the first things I did with C# was write an application that downloaded and parsed my online gaming stats while playing Halo 2. From there, I loaded all of the information into a database and redisplayed it in ASP.NET. In retrospect, the code was horrendous, but it was a fun exercise.

Another exercise was to parse the XML file for my iTunes music library, load it into a database, and (of course) display bits of it in ASP.NET.

Anyway, find ways to work with things you enjoy, be it games, music, television, or whatever.

Anthony Pegram
A: 

I recently developed a sudoku solver and a 8Queens solver.

I made the sudoku solver in console where the puzzle itself was hard coded in the project. You could try to make it possible to use a textfile as an input. I implemented a brute force algorithm witch works with recursion. It's is nice to develop such a solver and once you're ready there probably will be lots of improvements possible.

The 8Queens solver learned me two things. First I had to made a chessboard, which I did with forms. Learned me about Pens, Brushes and drawing. Also it was a nice practice for recursion which you have to do a lot before you understand it...

A: 

I'd suggest writing a command-line tool that does something that maybe can't be done by anything else.

The one thing that springs to mind is something that applies XSL stylesheets to XML files and spits out the output. There's sample code everywhere but no straightforward Windows tool that I've seen.

Potential benefits of this approach are that you end up with a useful tool and you then have the option of making it open-source to get additional input/support.

JBRWilkinson
A: 

Well they are all tough to do, so i suggest using the copy paste method with my Blackjack app remember to reference add system speech synth using System; using System.Speech.Synthesis;

namespace Blackjack

{

 class Blackjack  

 {  

     static string[] playerCards = new string[11];  

     static string hitOrStay = "";  

     static int total = 0, count = 1, dealerTotal = 0;  

     static Random cardRandomizer = new Random();  



     static void Main(string[] args)  

     {
         using (SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer())
         {
             Console.Title = "Blackjack";
             synth.Speak("Please enter your blackjack table's name followed by a comma then the secondary name (AKA table number)");
             string bjtn = Console.ReadLine();
             Console.Clear();



             Console.Title = bjtn;
         }

         Start();  


     }  



     static void Start()  

     {  

         dealerTotal = cardRandomizer.Next(15, 22);  

         playerCards[0] = Deal();  

         playerCards[1] = Deal();  

         do 

         {  

             Console.WriteLine("Welcome to Blackjack! You were dealed " + playerCards[0] + " and " + playerCards[1] + ". \nYour total is " + total + ".\nWould you like to hit or stay? h for hit s for stay.");  

            hitOrStay = Console.ReadLine().ToLower();  

        } while (!hitOrStay.Equals("h") && !hitOrStay.Equals("s"));  

        Game();  

    }  



     static void Game()  

     {  

         if (hitOrStay.Equals("h"))  

         {  

             Hit();  

         }  

         else if (hitOrStay.Equals("s"))  

         {  

            if (total > dealerTotal && total <= 21)  
             {  

                 Console.WriteLine("\nCongrats! You won the game! The dealer's total was " + dealerTotal + ".\nWould you like to play again? y/n");  

                 PlayAgain();  

             }  

             else if (total < dealerTotal)  

             {  

                 Console.WriteLine("\nSorry, you lost! The dealer's total was " + dealerTotal + ".\nWould you like to play again? y/n");  

                 PlayAgain();  

            }  



        }  

         Console.ReadLine();  

     }  



     static string Deal()  

     {  

        string Card = "";  

        int cards = cardRandomizer.Next(1, 14);  

        switch (cards)  

         {  

            case 1: Card = "Two"; total += 2;  

               break;  

            case 2: Card = "Three"; total += 3;  

                 break;  

             case 3: Card = "Four"; total += 4;  

                 break;  

            case 4: Card = "Five"; total += 5;  

                 break;  

             case 5: Card = "Six"; total += 6;  

                 break;  

            case 6: Card = "Seven"; total += 7;  

                 break;  

             case 7: Card = "Eight"; total += 8;  

                break;  

             case 8: Card = "Nine"; total += 9;  

                break;  

             case 9: Card = "Ten"; total += 10;  

                 break;  

             case 10: Card = "Jack"; total += 10;  

                 break;  

            case 11: Card = "Queen"; total += 10;  

                 break;  

             case 12: Card = "King"; total += 10;  

                 break;  

             case 13: Card = "Ace"; total += 11;  

                 break;  

             default: Card = "2"; total += 2;  

                 break;  

         }  

         return Card;  

     }  


     static void Hit()  

     {  

         count += 1;  

        playerCards[count] = Deal();  

        Console.WriteLine("\nYou were dealed a(n) " + playerCards[count] + ".\nYour new total is " + total + ".");  

         if (total.Equals(21))  

         {  

            Console.WriteLine("\nYou got Blackjack! The dealer's total was " + dealerTotal + ".\nWould you like to play again?");  

             PlayAgain();  

         }  

        else if (total > 21)  

         {  

             Console.WriteLine("\nYou busted, therefore you lost. Sorry. The dealer's total was " + dealerTotal + ".\nWould you like to play again? y/n");  

             PlayAgain();  

        }  

        else if (total < 21)  

         {  

             do 

             {  

                Console.WriteLine("\nWould you like to hit or stay? h for hit s for stay");  

                 hitOrStay = Console.ReadLine().ToLower();  

             } while (!hitOrStay.Equals("h") && !hitOrStay.Equals("s"));  

             Game();  

         }  

     }  



     static void PlayAgain()  

     {  

        string playAgain = "";  

        do 

         {  

             playAgain = Console.ReadLine().ToLower();  

         } while (!playAgain.Equals("y") && !playAgain.Equals("n"));  

        if (playAgain.Equals("y"))  

         {  

             Console.WriteLine("\nPress enter to restart the game!");  

             Console.ReadLine();  

             Console.Clear();  

            dealerTotal = 0;  

             count = 1;  

             total = 0;  

             Start();  

        }

        else if (playAgain.Equals("n"))
        {
            using (SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer())
            {
                synth.Speak("\nPress enter to close Black jack." + dealerTotal);
            }

            ConsoleKeyInfo info = Console.ReadKey();
            if (info.Key == ConsoleKey.Enter)
            {

                Environment.Exit(0);
            }
            else
            {

                Console.Read();
                Environment.Exit(0);
            }
        }
     }  

 }  

}

Eion kihlgren-Scott