Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# help?

C# help?

Scheduled Pinned Locked Moved C#
csharphelpquestion
12 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brian Reiber
    wrote on last edited by
    #1

    Thank you so much for your help. Now it is giving me new errors for something else and I dont understand. Does anyone know?

    public static void Main()
    {
    stringinput,firstname,lastname;
    double idium;
    int password, choice;
    string name;

    Console.WriteLine("Enter your firstname:");
    Console.WriteLine("Enter your ID Number:");
    input = Console.ReadLine();
    FirstName = Convert.ToString(input);
    
    
    Console.WriteLine("Enter your lastname:");
    input = Console.ReadLine();
    LastName = Convert.ToString(input);
    

    }

    public static void checkout()
    {

    Console.Write("You are ready to check out.");
    
    double\[\] payRate;
    payRate = new double\[4\];
    payRate\[0\] = 3.00;
    payRate\[1\] = 4.15;
    payRate\[2\] = 6.42;
    payRate\[3\] = 7.95;
    
    for(int x = 0; x < 4; ++x)
    Console.WriteLine("Pay rate {0} is {1}", x, payRate\[x\].ToString("C"));
    

    }

    }

    P L P D D 8 Replies Last reply
    0
    • B Brian Reiber

      Thank you so much for your help. Now it is giving me new errors for something else and I dont understand. Does anyone know?

      public static void Main()
      {
      stringinput,firstname,lastname;
      double idium;
      int password, choice;
      string name;

      Console.WriteLine("Enter your firstname:");
      Console.WriteLine("Enter your ID Number:");
      input = Console.ReadLine();
      FirstName = Convert.ToString(input);
      
      
      Console.WriteLine("Enter your lastname:");
      input = Console.ReadLine();
      LastName = Convert.ToString(input);
      

      }

      public static void checkout()
      {

      Console.Write("You are ready to check out.");
      
      double\[\] payRate;
      payRate = new double\[4\];
      payRate\[0\] = 3.00;
      payRate\[1\] = 4.15;
      payRate\[2\] = 6.42;
      payRate\[3\] = 7.95;
      
      for(int x = 0; x < 4; ++x)
      Console.WriteLine("Pay rate {0} is {1}", x, payRate\[x\].ToString("C"));
      

      }

      }

      P Offline
      P Offline
      Paladin2000
      wrote on last edited by
      #2

      I will agree with Pete in your last posting - "This is fairly basic stuff". Perhaps you could look into a few online tutorials? That would probably help you to learn this better than asking several questions here. Rather than trying to make a given block of code work, I would advise to learn the fundamentals instead...

      1 Reply Last reply
      0
      • B Brian Reiber

        Thank you so much for your help. Now it is giving me new errors for something else and I dont understand. Does anyone know?

        public static void Main()
        {
        stringinput,firstname,lastname;
        double idium;
        int password, choice;
        string name;

        Console.WriteLine("Enter your firstname:");
        Console.WriteLine("Enter your ID Number:");
        input = Console.ReadLine();
        FirstName = Convert.ToString(input);
        
        
        Console.WriteLine("Enter your lastname:");
        input = Console.ReadLine();
        LastName = Convert.ToString(input);
        

        }

        public static void checkout()
        {

        Console.Write("You are ready to check out.");
        
        double\[\] payRate;
        payRate = new double\[4\];
        payRate\[0\] = 3.00;
        payRate\[1\] = 4.15;
        payRate\[2\] = 6.42;
        payRate\[3\] = 7.95;
        
        for(int x = 0; x < 4; ++x)
        Console.WriteLine("Pay rate {0} is {1}", x, payRate\[x\].ToString("C"));
        

        }

        }

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Apart from the errors (tip: C# is case-sensitive), what's up with this?

        Brian Reiber wrote:

        input = Console.ReadLine(); LastName = Convert.ToString(input);

        It's already string, why convert a string to a string? ILSpy confirms that the overload of Convert.ToString that takes a string argument just returns that string:

        public static string ToString(string value)
        {
        return value;
        }

        1 Reply Last reply
        0
        • B Brian Reiber

          Thank you so much for your help. Now it is giving me new errors for something else and I dont understand. Does anyone know?

          public static void Main()
          {
          stringinput,firstname,lastname;
          double idium;
          int password, choice;
          string name;

          Console.WriteLine("Enter your firstname:");
          Console.WriteLine("Enter your ID Number:");
          input = Console.ReadLine();
          FirstName = Convert.ToString(input);
          
          
          Console.WriteLine("Enter your lastname:");
          input = Console.ReadLine();
          LastName = Convert.ToString(input);
          

          }

          public static void checkout()
          {

          Console.Write("You are ready to check out.");
          
          double\[\] payRate;
          payRate = new double\[4\];
          payRate\[0\] = 3.00;
          payRate\[1\] = 4.15;
          payRate\[2\] = 6.42;
          payRate\[3\] = 7.95;
          
          for(int x = 0; x < 4; ++x)
          Console.WriteLine("Pay rate {0} is {1}", x, payRate\[x\].ToString("C"));
          

          }

          }

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Something else that you have failed to do is to show the actual error message that you receive. Don't expect others to be able to see what's happening on your PC when you try compiling this.

          Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

          1 Reply Last reply
          0
          • B Brian Reiber

            Thank you so much for your help. Now it is giving me new errors for something else and I dont understand. Does anyone know?

            public static void Main()
            {
            stringinput,firstname,lastname;
            double idium;
            int password, choice;
            string name;

            Console.WriteLine("Enter your firstname:");
            Console.WriteLine("Enter your ID Number:");
            input = Console.ReadLine();
            FirstName = Convert.ToString(input);
            
            
            Console.WriteLine("Enter your lastname:");
            input = Console.ReadLine();
            LastName = Convert.ToString(input);
            

            }

            public static void checkout()
            {

            Console.Write("You are ready to check out.");
            
            double\[\] payRate;
            payRate = new double\[4\];
            payRate\[0\] = 3.00;
            payRate\[1\] = 4.15;
            payRate\[2\] = 6.42;
            payRate\[3\] = 7.95;
            
            for(int x = 0; x < 4; ++x)
            Console.WriteLine("Pay rate {0} is {1}", x, payRate\[x\].ToString("C"));
            

            }

            }

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            What errors are you getting?

            Brian Reiber wrote:

            stringinput

            I suspect you mean string input

            Brian Reiber wrote:

            input = Console.ReadLine(); FirstName = Convert.ToString(input);

            Why not simply FirstName = Console.ReadLine(); ?

            Brian Reiber wrote:

            Convert

            I recommend never using Convert other than Convert.ChangeType

            Brian Reiber wrote:

            {1} ... , payRate[x].ToString("C")

            Try using {1:C} instead of the ToString.

            1 Reply Last reply
            0
            • B Brian Reiber

              Thank you so much for your help. Now it is giving me new errors for something else and I dont understand. Does anyone know?

              public static void Main()
              {
              stringinput,firstname,lastname;
              double idium;
              int password, choice;
              string name;

              Console.WriteLine("Enter your firstname:");
              Console.WriteLine("Enter your ID Number:");
              input = Console.ReadLine();
              FirstName = Convert.ToString(input);
              
              
              Console.WriteLine("Enter your lastname:");
              input = Console.ReadLine();
              LastName = Convert.ToString(input);
              

              }

              public static void checkout()
              {

              Console.Write("You are ready to check out.");
              
              double\[\] payRate;
              payRate = new double\[4\];
              payRate\[0\] = 3.00;
              payRate\[1\] = 4.15;
              payRate\[2\] = 6.42;
              payRate\[3\] = 7.95;
              
              for(int x = 0; x < 4; ++x)
              Console.WriteLine("Pay rate {0} is {1}", x, payRate\[x\].ToString("C"));
              

              }

              }

              D Offline
              D Offline
              Deborah Palmer McCain
              wrote on last edited by
              #6

              Brian: I am going to echo the recommendations of another post. As a new (and I really cannot refer to myself as a developer, yet) I researched online tutorials and books that would provide a foundation for C#, and VS 2010. The following books have proven to be valuable resources: 1. Beginning C# Object Oriented Programming by Dan Clark (READ Chapter 5) 2. Visual C# 2010 Recipes by Jones and Freeman 3. HeadFirst C# by Stellman and Greene 4. Programming Language Pragmatics by Scott (buy it and put in on the bookshelf for a goal in understanding). It's beyond new developers, but it's a good feeling to go to the book and "get it" after study. 5. Herding Cats - A Primer for Programmers Who Lead Programmers by Rainwater (this book helps me understand those in the world of programming, as I come from the academic "world"). 6. Online tutorials available from Lynda.com My mentor (who has been programming since God was a child) says "Work on your errors for 2 hours, THEN ask for help". My greatest hurdle has been in understanding the vocabulary that is used, and I finally had to stop obsessing... It is what it is. Oh...Petzold's free online book (263 pages)was recommmended to me(Richard?), and is proving to be interesting, but I don't do well with books I cannot markup with pencil notations. Two other books have been recommended, but they are on my Amazon wish list. Code Complete, and New Programmer's Survival Manual. Looking at your code (I c/p'd into VS, and messed around with it), I was able to reduce the errors to 3, but then was stumped by my own ignorance...and I am not cheeky enough to make suggestions for changes. So your code helped me learn, so thank you. Best of luck.

              L 1 Reply Last reply
              0
              • B Brian Reiber

                Thank you so much for your help. Now it is giving me new errors for something else and I dont understand. Does anyone know?

                public static void Main()
                {
                stringinput,firstname,lastname;
                double idium;
                int password, choice;
                string name;

                Console.WriteLine("Enter your firstname:");
                Console.WriteLine("Enter your ID Number:");
                input = Console.ReadLine();
                FirstName = Convert.ToString(input);
                
                
                Console.WriteLine("Enter your lastname:");
                input = Console.ReadLine();
                LastName = Convert.ToString(input);
                

                }

                public static void checkout()
                {

                Console.Write("You are ready to check out.");
                
                double\[\] payRate;
                payRate = new double\[4\];
                payRate\[0\] = 3.00;
                payRate\[1\] = 4.15;
                payRate\[2\] = 6.42;
                payRate\[3\] = 7.95;
                
                for(int x = 0; x < 4; ++x)
                Console.WriteLine("Pay rate {0} is {1}", x, payRate\[x\].ToString("C"));
                

                }

                }

                D Offline
                D Offline
                DaveyM69
                wrote on last edited by
                #7

                Please give your questions a meaningful subject. Every question posted in this forum is from someone looking for 'C# Help'. If you are getting error messages, first of all examine them and they will normally give you enough information to fix them! I recommend turning on line numbers in Visual Studio if you haven't already: Tools|Option|Editor|C# and check the Line numbers box. Secondly, use a search engine of your choice and search for the error message (excluding any parts specific to your project). Thirdly, if you still need help, post the error message here and indicate on which line of your code posted it actually fails on. These will save people who wish to help you a lot of time and will make it far more probable that you will get a helpful answer.

                Dave
                Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
                BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

                L 1 Reply Last reply
                0
                • B Brian Reiber

                  Thank you so much for your help. Now it is giving me new errors for something else and I dont understand. Does anyone know?

                  public static void Main()
                  {
                  stringinput,firstname,lastname;
                  double idium;
                  int password, choice;
                  string name;

                  Console.WriteLine("Enter your firstname:");
                  Console.WriteLine("Enter your ID Number:");
                  input = Console.ReadLine();
                  FirstName = Convert.ToString(input);
                  
                  
                  Console.WriteLine("Enter your lastname:");
                  input = Console.ReadLine();
                  LastName = Convert.ToString(input);
                  

                  }

                  public static void checkout()
                  {

                  Console.Write("You are ready to check out.");
                  
                  double\[\] payRate;
                  payRate = new double\[4\];
                  payRate\[0\] = 3.00;
                  payRate\[1\] = 4.15;
                  payRate\[2\] = 6.42;
                  payRate\[3\] = 7.95;
                  
                  for(int x = 0; x < 4; ++x)
                  Console.WriteLine("Pay rate {0} is {1}", x, payRate\[x\].ToString("C"));
                  

                  }

                  }

                  G Offline
                  G Offline
                  gymmy
                  wrote on last edited by
                  #8

                  for loop x++

                  1 Reply Last reply
                  0
                  • B Brian Reiber

                    Thank you so much for your help. Now it is giving me new errors for something else and I dont understand. Does anyone know?

                    public static void Main()
                    {
                    stringinput,firstname,lastname;
                    double idium;
                    int password, choice;
                    string name;

                    Console.WriteLine("Enter your firstname:");
                    Console.WriteLine("Enter your ID Number:");
                    input = Console.ReadLine();
                    FirstName = Convert.ToString(input);
                    
                    
                    Console.WriteLine("Enter your lastname:");
                    input = Console.ReadLine();
                    LastName = Convert.ToString(input);
                    

                    }

                    public static void checkout()
                    {

                    Console.Write("You are ready to check out.");
                    
                    double\[\] payRate;
                    payRate = new double\[4\];
                    payRate\[0\] = 3.00;
                    payRate\[1\] = 4.15;
                    payRate\[2\] = 6.42;
                    payRate\[3\] = 7.95;
                    
                    for(int x = 0; x < 4; ++x)
                    Console.WriteLine("Pay rate {0} is {1}", x, payRate\[x\].ToString("C"));
                    

                    }

                    }

                    D Offline
                    D Offline
                    DaveyM69
                    wrote on last edited by
                    #9

                    OK, you've had a bit of time to fix your errors and enough hints... Here is working code with a) reduntant items removed b) code styling and variable/method names changed where appropriate c) other suggestions applied d) the double array moved outside of the method - unless it's going to be different every time (as it's hardcoded I assume not) then it makes no sense to keep it there Study it and the differences and see if you can learn from it:

                    private static readonly double\[\] PayRate = 
                        new double\[4\] { 
                            3.00, 
                            4.15, 
                            6.42, 
                            7.95 };
                    
                    static void Main()
                    {
                        Console.WriteLine("Enter your forename:");
                        string forename = Console.ReadLine();
                        Console.WriteLine("Enter your surname:");
                        string surname = Console.ReadLine();
                        Checkout();
                        Console.ReadKey();
                    }
                    
                    private static void Checkout()
                    {
                        Console.WriteLine("You are ready to check out.");
                        for (int i = 0; i < PayRate.Length; i++)
                            Console.WriteLine("Pay rate {0} is {1:C}", i, PayRate\[i\]);
                    }
                    

                    Dave
                    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
                    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

                    1 Reply Last reply
                    0
                    • D DaveyM69

                      Please give your questions a meaningful subject. Every question posted in this forum is from someone looking for 'C# Help'. If you are getting error messages, first of all examine them and they will normally give you enough information to fix them! I recommend turning on line numbers in Visual Studio if you haven't already: Tools|Option|Editor|C# and check the Line numbers box. Secondly, use a search engine of your choice and search for the error message (excluding any parts specific to your project). Thirdly, if you still need help, post the error message here and indicate on which line of your code posted it actually fails on. These will save people who wish to help you a lot of time and will make it far more probable that you will get a helpful answer.

                      Dave
                      Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
                      BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

                      L Offline
                      L Offline
                      Luc Pattyn
                      wrote on last edited by
                      #10

                      :thumbsup:

                      Luc Pattyn [My Articles] Nil Volentibus Arduum

                      1 Reply Last reply
                      0
                      • D Deborah Palmer McCain

                        Brian: I am going to echo the recommendations of another post. As a new (and I really cannot refer to myself as a developer, yet) I researched online tutorials and books that would provide a foundation for C#, and VS 2010. The following books have proven to be valuable resources: 1. Beginning C# Object Oriented Programming by Dan Clark (READ Chapter 5) 2. Visual C# 2010 Recipes by Jones and Freeman 3. HeadFirst C# by Stellman and Greene 4. Programming Language Pragmatics by Scott (buy it and put in on the bookshelf for a goal in understanding). It's beyond new developers, but it's a good feeling to go to the book and "get it" after study. 5. Herding Cats - A Primer for Programmers Who Lead Programmers by Rainwater (this book helps me understand those in the world of programming, as I come from the academic "world"). 6. Online tutorials available from Lynda.com My mentor (who has been programming since God was a child) says "Work on your errors for 2 hours, THEN ask for help". My greatest hurdle has been in understanding the vocabulary that is used, and I finally had to stop obsessing... It is what it is. Oh...Petzold's free online book (263 pages)was recommmended to me(Richard?), and is proving to be interesting, but I don't do well with books I cannot markup with pencil notations. Two other books have been recommended, but they are on my Amazon wish list. Code Complete, and New Programmer's Survival Manual. Looking at your code (I c/p'd into VS, and messed around with it), I was able to reduce the errors to 3, but then was stumped by my own ignorance...and I am not cheeky enough to make suggestions for changes. So your code helped me learn, so thank you. Best of luck.

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #11

                        Deborah Palmer McCain wrote:

                        I don't do well with books I cannot markup with pencil notations.

                        You can always print all or part of a PDF.

                        Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

                        D 1 Reply Last reply
                        0
                        • L Lost User

                          Deborah Palmer McCain wrote:

                          I don't do well with books I cannot markup with pencil notations.

                          You can always print all or part of a PDF.

                          Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

                          D Offline
                          D Offline
                          Deborah Palmer McCain
                          wrote on last edited by
                          #12

                          Yes, I read through part the book, and will be printing it so I can mark it. Truly a valuable resource, thank you again. Deborah

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups