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. I need help with C#

I need help with C#

Scheduled Pinned Locked Moved C#
csharphelpvisual-studio
11 Posts 9 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.
  • A Alex501

    I can't compile this code in visual studio I get an error. Could somebody help me. class Recurse { public void foo(int f) { Console.WriteLine("Handed "+f); if (f < 0) return; if ( f % 2 == 0) this.foo(f - 5); else this.foo(f + 1); } } class What_Does_This_Code_Print { public void RunExercise() { Recurse recurser = new Recurse(); recurser.foo(10); } }

    L Offline
    L Offline
    Lord Kixdemp
    wrote on last edited by
    #2
    1. Place your code around code and pre tags so it looks nicer. 2) What error did you get? 3) Does it specify a line number?

    Windows Calculator told me I will die at 28. :(

    L 1 Reply Last reply
    0
    • A Alex501

      I can't compile this code in visual studio I get an error. Could somebody help me. class Recurse { public void foo(int f) { Console.WriteLine("Handed "+f); if (f < 0) return; if ( f % 2 == 0) this.foo(f - 5); else this.foo(f + 1); } } class What_Does_This_Code_Print { public void RunExercise() { Recurse recurser = new Recurse(); recurser.foo(10); } }

      G Offline
      G Offline
      Gareth H
      wrote on last edited by
      #3

      Alex501, When you make a post, make the subject of use not "i need help", we know that already. Also, post the error you get. Regards, Gareth.

      1 Reply Last reply
      0
      • A Alex501

        I can't compile this code in visual studio I get an error. Could somebody help me. class Recurse { public void foo(int f) { Console.WriteLine("Handed "+f); if (f < 0) return; if ( f % 2 == 0) this.foo(f - 5); else this.foo(f + 1); } } class What_Does_This_Code_Print { public void RunExercise() { Recurse recurser = new Recurse(); recurser.foo(10); } }

        E Offline
        E Offline
        Ennis Ray Lynch Jr
        wrote on last edited by
        #4

        Your code is fine. Perhaps you forget to include the System namespace?

        Need a C# Consultant? I'm available.
        Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

        1 Reply Last reply
        0
        • A Alex501

          I can't compile this code in visual studio I get an error. Could somebody help me. class Recurse { public void foo(int f) { Console.WriteLine("Handed "+f); if (f < 0) return; if ( f % 2 == 0) this.foo(f - 5); else this.foo(f + 1); } } class What_Does_This_Code_Print { public void RunExercise() { Recurse recurser = new Recurse(); recurser.foo(10); } }

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

          Alex501 wrote:

          I need help with C#

          Don't we all?!? That's why we're here ;)

          Dave

          D 1 Reply Last reply
          0
          • D DaveyM69

            Alex501 wrote:

            I need help with C#

            Don't we all?!? That's why we're here ;)

            Dave

            D Offline
            D Offline
            DeepToot
            wrote on last edited by
            #6

            sounds like a homework question to me.

            Steve Welborn Software Engineer Inrange Consulting

            D 1 Reply Last reply
            0
            • D DeepToot

              sounds like a homework question to me.

              Steve Welborn Software Engineer Inrange Consulting

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

              Probably not as his code compiles fine

              Dave

              J 1 Reply Last reply
              0
              • A Alex501

                I can't compile this code in visual studio I get an error. Could somebody help me. class Recurse { public void foo(int f) { Console.WriteLine("Handed "+f); if (f < 0) return; if ( f % 2 == 0) this.foo(f - 5); else this.foo(f + 1); } } class What_Does_This_Code_Print { public void RunExercise() { Recurse recurser = new Recurse(); recurser.foo(10); } }

                R Offline
                R Offline
                Ravenet
                wrote on last edited by
                #8

                Hi Alex501 can you tell me here error message also. thanks

                Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com

                1 Reply Last reply
                0
                • L Lord Kixdemp
                  1. Place your code around code and pre tags so it looks nicer. 2) What error did you get? 3) Does it specify a line number?

                  Windows Calculator told me I will die at 28. :(

                  L Offline
                  L Offline
                  Le centriste
                  wrote on last edited by
                  #9
                  1. When is your homework due?
                  1 Reply Last reply
                  0
                  • D DaveyM69

                    Probably not as his code compiles fine

                    Dave

                    J Offline
                    J Offline
                    J4amieC
                    wrote on last edited by
                    #10

                    you sure? Tried concatenating a string and an int recently?

                    D 1 Reply Last reply
                    0
                    • J J4amieC

                      you sure? Tried concatenating a string and an int recently?

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

                      J4amieC wrote:

                      Tried concatenating a string and an int recently?

                      Yes, when testing his code - I wouldn't have done it, but when writing to the console it compiles and works. Try the code below!

                      static void Main()
                      {
                      int i = 5;
                      string s = "Test";
                      Console.WriteLine(s + i);
                      Console.ReadKey();
                      }

                      Dave

                      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