Click here to Skip to main content
15,892,059 members
Home / Discussions / C#
   

C#

 
GeneralRe: Review: CLR via C# Book Pin
Richard MacCutchan14-May-13 21:05
mveRichard MacCutchan14-May-13 21:05 
GeneralRe: Review: CLR via C# Book Pin
Mohammed Hameed14-May-13 21:59
professionalMohammed Hameed14-May-13 21:59 
QuestionCase Insensitive Replace Not Working Pin
cjb11012-May-13 23:09
cjb11012-May-13 23:09 
AnswerRe: Case Insensitive Replace Not Working Pin
jschell13-May-13 8:12
jschell13-May-13 8:12 
GeneralRe: Case Insensitive Replace Not Working Pin
cjb11013-May-13 21:42
cjb11013-May-13 21:42 
GeneralIf statements in my Main method? Pin
N8tiv12-May-13 15:16
N8tiv12-May-13 15:16 
GeneralRe: If statements in my Main method? Pin
Richard MacCutchan12-May-13 21:16
mveRichard MacCutchan12-May-13 21:16 
GeneralMethods, Parameters, Arguments… Oh my! Pin
N8tiv12-May-13 9:29
N8tiv12-May-13 9:29 
My exercise/homework assignment:
Build a C# program/application to find the power of the first number with the second number and get these numbers from the keyboard input.

I was able to successfully build this in one code block under the main method.
To me, it wasn't exactly boring because I'm just starting out.
To you old pros, you'll probably rolling your eyes. Poke tongue | ;-P

I know there's probably some shortcut techniques I could have used, but… I'm just a beginner, bear with me.

yOrn = Console.Read();
That is the line where I'm getting stuck.

Visual Studio's error is:
cannot implicitly convert type 'int' to ' char'. And explicit conversion exists(are you missing a cast?)

Smart aleck compiler anyway. OMG | :OMG:

No! I am not missing a cast. Am I?Confused | :confused:

At least I thought I didn't need a cast, it's in a new code block and its own method.

I was also thinking (dangerous I know). Poke tongue | ;-P

For each method, minus the main method.
Creating separate classes with their own methods, that way there is no mistaking on the intention of each method?

Would that take care of the compiler asking me if I'm missing a cast?


<pre lang="c#">
using System;

namespace CalculatetothePowerof
{
class Program
{
static void Main()
{
tellUser();
firstUserNum();
YesOrNo();
}

private static void tellUser()
{
Console.Write("Enter your first number:\n");
}

private static void firstUserNum()
{
int userIntValue;
string userValue;
userValue = Console.ReadLine();
Console.WriteLine("You entered {0}?\n", userValue);
userIntValue = Convert.ToInt32(userValue);
}

private static void YesOrNo()
{
Console.WriteLine("If that is correct, press the letter y.");
char yOrn;
yOrn = Console.Read();

//Console.ReadKey();
}
}
}
</pre>

<a href="http://www.widmarkrob.com">My Coding Journey</a>
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
dusty_dex12-May-13 10:06
dusty_dex12-May-13 10:06 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
N8tiv12-May-13 10:16
N8tiv12-May-13 10:16 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
N8tiv12-May-13 10:21
N8tiv12-May-13 10:21 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
N8tiv12-May-13 10:23
N8tiv12-May-13 10:23 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
dusty_dex12-May-13 10:32
dusty_dex12-May-13 10:32 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
N8tiv12-May-13 11:08
N8tiv12-May-13 11:08 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
N8tiv12-May-13 10:40
N8tiv12-May-13 10:40 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
Richard MacCutchan12-May-13 21:09
mveRichard MacCutchan12-May-13 21:09 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
N8tiv12-May-13 21:40
N8tiv12-May-13 21:40 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
Richard MacCutchan12-May-13 23:16
mveRichard MacCutchan12-May-13 23:16 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
N8tiv13-May-13 2:21
N8tiv13-May-13 2:21 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
Keith Barrow12-May-13 23:38
professionalKeith Barrow12-May-13 23:38 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
Richard MacCutchan12-May-13 23:56
mveRichard MacCutchan12-May-13 23:56 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
Pete O'Hanlon13-May-13 0:36
mvePete O'Hanlon13-May-13 0:36 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
Richard MacCutchan13-May-13 0:38
mveRichard MacCutchan13-May-13 0:38 
QuestionJust a simple question Pin
Jesús Frías12-May-13 6:13
Jesús Frías12-May-13 6:13 
AnswerRe: Just a simple question Pin
Abhinav S12-May-13 6:19
Abhinav S12-May-13 6:19 

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.