0

I was hoping you guys could help me out as you have in the past. I am kind of new to C# coming from C++.
I get two of each of these errors.

C:\Users\Hector Rosario\Documents\Visual Studio 2008\Projects\ConsoleApplication2\ConsoleApplication2\Program.cs(51,39): error CS1518: Expected class, delegate, enum, interface, or struct
C:\Users\Hector Rosario\Documents\Visual Studio 2008\Projects\ConsoleApplication2\ConsoleApplication2\Program.cs(57,9): error CS1022: Type or namespace definition, or end-of-file expected

Here is what I am working on

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            
            string Name;
            bool Life;
           string choose;
        
            string Sex;
            Console.WriteLine("Welcome to Hector Rosario's Character Generator.");
              Console.Write("Please enter your name: ");
            Name = Console.ReadLine();
            Console.WriteLine("Your character's age is {0}", age);
            int age = GenerateRandomInteger(10, 40);
            Console.WriteLine("Do you want your character to be male or female?\n Prees m or f to make your choice.");
            switch (choose)
                {
                    case "m":
                        Sex = "Your character is male";
                        break;
                    case "f":
                        Sex = "Your character is female";
                        break;

                       default:
                        Sex = "I'm sorry but uh... last I checked there were only two sexes, male and female.";
                        break;
                }//end switch statement

                Console.WriteLine();
                Console.WriteLine(Sex);
                Console.WriteLine();
                Console.WriteLine("Press [ENTER] to Exit");
                Console.ReadLine();

}
           
        }//end class "switchStatement
    private static int GenerateRandomInteger(int intMin, int intMax)
        {
            //Create a new instance of the class Random
            Random randomNumber = new Random();
            //Generate a random number using intMin as the minimum and intMax as the maximum
            return randomNumber.Next(intMin, intMax);
        }//end of number generator
        
          
        }

        


     
    }
1
Contributor
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Pikachumanson
0

Never mind, I fixed it. This is how I did it.

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            
            string Name;
            bool Life;
           string choose = "Ok, ";
           int age = GenerateRandomInteger(10, 40);
            
            string Sex;
            Console.WriteLine("Welcome to Hector Rosario's Character Generator.");
              Console.Write("Please enter your name: ");
            Name = Console.ReadLine();
            Console.WriteLine("Your character's age is {0}", age);
            
            Console.WriteLine("Do you want your character to be male or female?\n Prees m or f to make your choice.");
            
            switch (choose)
                {
                    case "m":
                        Sex = "Your character is male";
                        break;
                    case "f":
                        Sex = "Your character is female";
                        break;

                       default:
                        Sex = "I'm sorry but uh... last I checked there were only two sexes, male and female.";
                        break;
                }//end switch statement

                Console.WriteLine();
                Console.WriteLine(Sex);
                Console.WriteLine();
                Console.WriteLine("Press [ENTER] to Exit");
                Console.ReadLine();

}
       private static int GenerateRandomInteger(int intMin, int intMax)
        {
            //Create a new instance of the class Random
            Random randomNumber = new Random();
            //Generate a random number using intMin as the minimum and intMax as the maximum
            return randomNumber.Next(intMin, intMax);
        }//end of number generator    
        }//end class "switchStatement
    
        
          
        }

It didn't have the intended results I wanted but it compiled. I can get to to making that switch working now!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.