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

C#

 
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 
GeneralRe: Method Not Returning a Value Pin
N8tiv15-May-13 23:10
N8tiv15-May-13 23:10 
Okay, Some guy at MSDN was getting a little frustrated… So, he wrote out the program… Probably the way you guys would have done also… It looks very clean and it's only about 35 lines of code…

Anyway, I was looking at his code and studying it a little bit… I thought I would try to apply some of it to what I have written so I could understand it better…

It does look a little better…

Now, where I'm getting stuck is at:
Program.AcceptValueTwo(message2);

I also tried it without the "Program."

I get blue squiggly lines underneath (message2)
the name does not exist in the current context

Let's try to focus on this part before I tackle implementing the do while loop.
I'll still have to go back to my book and probably watch a few more YouTube videos to get the basics of the do while loop.



C#
using System;

namespace CalculatetothePowerof
{
    class Program
    {
        static void Main()
        {
            int valOne = AcceptValueOne("Enter your first number:");
            int valTwo = AcceptValueTwo("\nEnter your second number:");
            Console.WriteLine(Math.Pow(valOne, valTwo));
            Console.Read();
        }
        static int AcceptValueOne(string message)
        {
            Console.WriteLine(message);
            string valueOne = Console.ReadLine();
            int IntOne = 0;
            bool result = Int32.TryParse(valueOne, out IntOne);
            if (!result)
            {
                Console.WriteLine("Attempted conversion of '{0}' failed.", IntOne);
                AcceptValueOne(message);
            }
            Console.WriteLine("\n{0}", IntOne + ", is what you entered?\n\nPress lowercase y for yes\nPress lowercase n for no.");
            string yesNo = Console.ReadLine();
            if (yesNo == "y")
            {
                Program.AcceptValueTwo(message2);
            }
            if (yesNo != "y")
            {
                Console.Clear();
                AcceptValueOne(message);
            }
            return IntOne;
        }
        static int AcceptValueTwo(string message2)
        {
            Console.WriteLine(message2);
            string valueTwo = Console.ReadLine();
            int IntTwo = 0;
            bool result = Int32.TryParse(valueTwo, out IntTwo);
            if (!result)
            {
                Console.WriteLine("Attempted conversion of '{0}' failed.", IntTwo);
                AcceptValueTwo(message2);
            }
            Console.WriteLine("\n{0}", IntTwo + ", is what you entered?\n\nPress lowercase y for yes\nPress lowercase n for no.");
            string yesNo = Console.ReadLine();
            if (yesNo == "y")
            {
                return IntTwo;
            }
            if (yesNo != "y")
            {
                Console.Clear();
                AcceptValueTwo(message2);
            }
            return IntTwo;
        }
    }
}


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 
AnswerRe: Creating Images on Different Layers Pin
SledgeHammer0114-May-13 12:51
SledgeHammer0114-May-13 12:51 

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.