Click here to Skip to main content
15,900,108 members
Home / Discussions / C#
   

C#

 
QuestionC# Project On Image Processing Pin
Bishwajit Nepali31-May-13 23:47
Bishwajit Nepali31-May-13 23:47 
AnswerRe: C# Project On Image Processing Pin
Eddy Vluggen1-Jun-13 11:05
professionalEddy Vluggen1-Jun-13 11:05 
GeneralRe: C# Project On Image Processing Pin
Bishwajit Nepali24-Sep-13 8:29
Bishwajit Nepali24-Sep-13 8:29 
AnswerRe: C# Project On Image Processing Pin
Anna King3-Jun-13 3:00
professionalAnna King3-Jun-13 3:00 
AnswerRe: C# Project On Image Processing Pin
Pete O'Hanlon3-Jun-13 3:23
mvePete O'Hanlon3-Jun-13 3:23 
AnswerRe: C# Project On Image Processing Pin
Bishwajit Nepali3-Jun-13 6:12
Bishwajit Nepali3-Jun-13 6:12 
GeneralPracticing Passing Parameters Pin
N8tiv31-May-13 16:25
N8tiv31-May-13 16:25 
GeneralRe: Practicing Passing Parameters Pin
OriginalGriff31-May-13 21:15
mveOriginalGriff31-May-13 21:15 
WidmarkRob wrote:
I'm not taking any formal classes, I'm trying to learn this on my own time.

Stop doing that - it's a pretty poor way to do things. If you are following a book, or other training course, then fine, but if you are just trying to pick it up "randomly" as you go, then stop right now! Your will miss too much stuff, which can save you a lot of time and heartache later!

Having said that, your error is pretty simple, and the error message is pretty explicit:
use of unassigned local variable 'num' and 'num1'

What that means is that when you pass the value of the two variables to your UserInput method, you have not assigned them any value, so there is no value to send. Since at compile time it doesn't know anything about the UserInput method it complains, because the way you have defined things it has to assume that UserInput is expecting to use the value, not set it.

There are two ways to solve the problem: change the UserInput parameter to an out paramater - in which case no value is carried in, only out of the method:
C#
static void Main()
{
    int num;
    int num1;
    UserInput(out num);
    UserInput(out num1);
    Console.WriteLine(Math.Pow(num, num1));
}
static void UserInput(out int input)
{
    ...
Because an out parameter does not copy any data from the calling method, but modifies the variable when it returns. But then the compiler will very probably complain that input is not given a value in all code paths.

The better solution is to not pass anything in - return a value instead:
C#
static int UserInput()
{
But I don't think what you are doing is what the exercise calls for. I'm not quite sure what your instructions mean, but I suspect that what they should be doing is not reading values from the user at all - "program arguements" means something very different and specific here.
Where did you get the exercise? What was it related to?
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

GeneralRe: Practicing Passing Parameters Pin
N8tiv3-Jun-13 7:19
N8tiv3-Jun-13 7:19 
GeneralRe: Practicing Passing Parameters Pin
OriginalGriff3-Jun-13 7:59
mveOriginalGriff3-Jun-13 7:59 
GeneralRe: Practicing Passing Parameters Pin
Richard MacCutchan31-May-13 23:21
mveRichard MacCutchan31-May-13 23:21 
GeneralRe: Practicing Passing Parameters Pin
N8tiv3-Jun-13 1:02
N8tiv3-Jun-13 1:02 
GeneralRe: Practicing Passing Parameters Pin
Richard MacCutchan3-Jun-13 1:20
mveRichard MacCutchan3-Jun-13 1:20 
GeneralRe: Practicing Passing Parameters Pin
N8tiv3-Jun-13 2:39
N8tiv3-Jun-13 2:39 
GeneralRe: Practicing Passing Parameters Pin
Richard MacCutchan3-Jun-13 6:15
mveRichard MacCutchan3-Jun-13 6:15 
GeneralRe: Practicing Passing Parameters Pin
N8tiv3-Jun-13 21:01
N8tiv3-Jun-13 21:01 
GeneralRe: Practicing Passing Parameters Pin
Richard MacCutchan3-Jun-13 21:15
mveRichard MacCutchan3-Jun-13 21:15 
GeneralRe: Practicing Passing Parameters Pin
N8tiv3-Jun-13 3:46
N8tiv3-Jun-13 3:46 
GeneralRe: Practicing Passing Parameters Pin
Richard MacCutchan3-Jun-13 6:11
mveRichard MacCutchan3-Jun-13 6:11 
QuestionTo detect all USB devices. Pin
ravi inder jeet singh31-May-13 15:44
ravi inder jeet singh31-May-13 15:44 
AnswerRe: To detect all USB devices. Pin
Dave Kreskowiak1-Jun-13 6:51
mveDave Kreskowiak1-Jun-13 6:51 
QuestionSkype in C# Pin
Kevin Marois31-May-13 12:12
professionalKevin Marois31-May-13 12:12 
AnswerRe: Skype in C# Pin
Ron Beyer31-May-13 12:14
professionalRon Beyer31-May-13 12:14 
GeneralRe: Skype in C# Pin
Kevin Marois31-May-13 12:15
professionalKevin Marois31-May-13 12:15 
GeneralRe: Skype in C# Pin
Ron Beyer31-May-13 12:22
professionalRon Beyer31-May-13 12:22 

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.