Hey, trying to learn visual C, I found a code I'm trying to run, heres what it looks like right now: http://img77.imageshack.us/my.php?image=visualcqi1.jpg it compiles without errors, but how do you see the actual result of the code? Thanks.
Originally posted by: kamper
1) That isn't Visual C, it's c#, and console based
2) It isn't going to do anything because your main method exits without doing anything. IIRC, visual studio will pop up a command box for a command line application and it will close as soon as the program finishes so you'll just see a quick flash of it.
3) To run it, hit the lovely green arrow directly under the "Window" menu
Originally posted by: Markbnj
You need to pause and wait for a key at the end, otherwise the console exits too fast for you to see anything. Try Console.ReadKey or Console.ReadLine. The first method will return as soon as the user pressed a key. The second method will return when the user presses enter to end a line.
Originally posted by: EagleKeeper
Where are you outputing anything?
Originally posted by: EagleKeeper
First it does not look like your function is ever called.
Second where in your function(s) do you output anything?
Your function returns an integer. What is done by which ever code area that calls the functions.
I looks like you have a basic building block - the overall skeleton needs to be fleshed out.
Originally posted by: kamper
You should learn how to call functions at the same time as learning to write them. Stop using fun0() and put everything in the Main method for now.
Originally posted by: mOeeOm
The first code worked after using Console.Realine(), but now I'm trying a different code and the method doesn't work:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
}
int fun0()
{
int i;
for(i = 0; i < 100; i++)
if( i == 100 )
i = 0;
else
i *= 2;
Console.ReadLine();
return(i);
}
}
}
it compiles with no errors, but doesn't display anything.
Originally posted by: kamper
You should learn how to call functions at the same time as learning to write them. Stop using fun0() and put everything in the Main method for now.
That's one of the better apps I've had in a while :laugh:
Wtf? Assuming that even compiles, wouldn't it print something along the lines of the address of the method?Originally posted by: beggerking
console.writeline(fun0)
Originally posted by: kamper
Wtf? Assuming that even compiles, wouldn't it print something along the lines of the address of the method?Originally posted by: beggerking
console.writeline(fun0)
So you can call methods in c# without using parentheses?Originally posted by: SoftwareEng
no, it will simply call the function, take the result, and pass it to the writeline function. If fun0 takes an int and returns an int, we can do:Originally posted by: kamper
Wtf? Assuming that even compiles, wouldn't it print something along the lines of the address of the method?Originally posted by: beggerking
console.writeline(fun0)
console.writeline(fun0(fun0(fun0(fun0(1)))))
