Tutorials
Resources
Forum
Reviews
Communities
Interview
Jobs
Projects
Training
Your
Ad
Here
Silverlight Games
|
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Polls
|
Revenue Sharing
|
Lobby
|
Gift Shop
|
Prizes & Awards
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
srinivas kante...
(67)
Alwyn
(64)
Abhisek Panda
(42)
Last 7 Days
Alwyn
(728)
nishithraj
(512)
Gaurav Arora
(503)
more...
Resources
»
Errors and Solutions
»
General
»
Use of Unassigned Local Variable ‘n’
Posted Date: 28 Sep 2008
Resource Type:
Errors and Solutions
Category:
General
Author:
Bindu Bujji
Member Level:
Gold
Rating:
Points
: 4
This error message indicates that you declared a variable but didn't give it an initial value. This is usually an oversight, but it can occur when you really meant to pass a variable as an out argument to a method.
Take a look at the following example:
public class MyClass
{
public void SomeMethod()
{
int n; \\ Not initialized with a value.
\\ This is fine because C# only returns a value in n; it does not
\\ pass a value into the method.
OtherMethod(out n);
}
public void OtherMethod(out int n)
{
n = 1; \\ Value is assigned here.
}
}
In this case, n is not assigned a value inside of SomeMethod(), but it is assigned in OtherMethod(). Okay!
In fact, OtherMethod() ignores the value of an out argument as if it didn't exist — which it doesn't in this case.
Responses
Author:
Parvathi
02 May 2009
Member Level:
Gold
Points
: 1
While using out parameter both the method declaration and method definition should have the out keyword.
If the value is not initialized with in the method it gives an error.
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
to add tags.
Use of Unassigned Local Variable ‘n’
.
Post Feedback
This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must
Sign In
to post a response.
Next Resource:
How to solve error 'Expected Error' in dot net
Previous Resource:
'ClassName’ Does Not Implement Interface Member ‘MethodName’
Return to Discussion Resource Index
Post New Resource
Category:
General
Post resources and
earn money
!
More Resources
Cannot Implicitly Convert Type ‘x’ Into ‘y’ Error in C#
GET AND SET in VB .NET
Type Casting Problem in C#
Packages
Error in Trigger Generation in Oracle
NT AUTHORITY-NETWORK SERVICE does not have write access.
dotNet Slackers
About Us
Contact Us
Privacy Policy
Terms Of Use