I need help with C#
-
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); } }
-
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); } }
- Place your code around
code
andpre
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. :(
- Place your code around
-
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); } }
-
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); } }
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 -
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); } }
-
sounds like a homework question to me.
Steve Welborn Software Engineer Inrange Consulting
-
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); } }
Hi Alex501 can you tell me here error message also. thanks
Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com
-
- Place your code around
code
andpre
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. :(
- When is your homework due?
- Place your code around
-
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