Click here to Skip to main content
15,887,485 members
Home / Discussions / C#
   

C#

 
AnswerRe: Consuming REST service from C# code Pin
Abhinav S15-May-13 7:52
Abhinav S15-May-13 7:52 
QuestionWin7 FolderBrowser on ext. Dev doesn't work Pin
boogey4all.beds14-May-13 22:46
boogey4all.beds14-May-13 22:46 
AnswerRe: Win7 FolderBrowser on ext. Dev doesn't work Pin
dusty_dex15-May-13 0:27
dusty_dex15-May-13 0:27 
GeneralMethod Not Returning a Value Pin
N8tiv14-May-13 19:34
N8tiv14-May-13 19:34 
AnswerRe: Method Not Returning a Value Pin
parths14-May-13 20:05
parths14-May-13 20:05 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan14-May-13 21:24
mveRichard MacCutchan14-May-13 21:24 
GeneralRe: Method Not Returning a Value Pin
N8tiv15-May-13 20:29
N8tiv15-May-13 20:29 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan15-May-13 21:46
mveRichard MacCutchan15-May-13 21:46 
WidmarkRob wrote:
you old pros are probably wincing
Not at all, we all had to learn, and we're just trying to help you do the same. I would strongly recommend you take a look at .NET Book Zero[^], by Charles Petzold, one of the best writers of books on Windows programming.

As to your code, you are getting there but you still have an issue with the scope of your variables, and getting method return values. Your main method should be:
C#
static void Main()
{
    int valOne = AcceptValueOne();
    int valTwo = AcceptValueTwo();
    Console.WriteLine(Math.Pow(valOne, valTwo));
    Console.Read();
}

... when a method returns a value then you need to capture that value into a local variable on the call, as the local variables in the called method have gone out of scope and no longer exist. Also, within your AcceptValueOne and AcceptValueTwo methods, you are making recursive calls (calling a method from within itself), which could lead you to disappear up your own fundament. You should rewrite these methods to use loops which break out when correct values have been received, something like:
IntValue = -1;
do
{
    display the message
    read the response string
    try and convert the string to an integer storing in IntValue
    if the IntValue is not valid then set IntValue = -1
} while (IntValue == -1);
return IntValue;

Use the best guess

GeneralRe: Method Not Returning a Value Pin
N8tiv15-May-13 23:10
N8tiv15-May-13 23:10 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan16-May-13 1:17
mveRichard MacCutchan16-May-13 1:17 
GeneralRe: Method Not Returning a Value Pin
N8tiv16-May-13 4:27
N8tiv16-May-13 4:27 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan16-May-13 5:02
mveRichard MacCutchan16-May-13 5:02 
GeneralRe: Method Not Returning a Value Pin
N8tiv16-May-13 6:13
N8tiv16-May-13 6:13 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan16-May-13 6:46
mveRichard MacCutchan16-May-13 6:46 
GeneralRe: Method Not Returning a Value Pin
N8tiv16-May-13 7:42
N8tiv16-May-13 7:42 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan16-May-13 20:40
mveRichard MacCutchan16-May-13 20:40 
GeneralRe: Method Not Returning a Value Pin
N8tiv17-May-13 11:31
N8tiv17-May-13 11:31 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan17-May-13 22:50
mveRichard MacCutchan17-May-13 22:50 
GeneralRe: Method Not Returning a Value Pin
Pete O'Hanlon14-May-13 23:07
mvePete O'Hanlon14-May-13 23:07 
GeneralRe: Method Not Returning a Value Pin
N8tiv15-May-13 20:37
N8tiv15-May-13 20:37 
GeneralRe: Method Not Returning a Value Pin
Pete O'Hanlon15-May-13 23:50
mvePete O'Hanlon15-May-13 23:50 
GeneralRe: Method Not Returning a Value Pin
N8tiv16-May-13 0:29
N8tiv16-May-13 0:29 
GeneralRe: Method Not Returning a Value Pin
Pete O'Hanlon16-May-13 0:36
mvePete O'Hanlon16-May-13 0:36 
QuestionCreating Images on Different Layers Pin
ASPnoob14-May-13 11:40
ASPnoob14-May-13 11:40 
AnswerRe: Creating Images on Different Layers Pin
Ravi Bhavnani14-May-13 11:48
professionalRavi Bhavnani14-May-13 11:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.