Questions tagged [unassigned-variable]
93 questions
0
votes
3 answers
Use of Unassigned Local variable when adding item in listview
I'm trying to compare if item is already existing in listview.
It says :
Use of unassigned local variable 'alreadyInList'
bool alreadyInList;
foreach (var itm in lvCart.Items)
{
if (itm == item)
{
alreadyInList = true;
…

bluffer
- 31
- 10
0
votes
3 answers
Attempting to order a list using IOrderedEnumerable in C#
I am attempting to read in a .csv file, do some formatting, split each line up into its column data and add the new array of seperated column data in to a list of arrays. Then I want to order the list in different ways. Currently just by username…

crmepham
- 4,676
- 19
- 80
- 155
0
votes
4 answers
C++ Union fields not set correcly
I have a templated union type NodeType.
The problem is that upon assignement of its variable field are not set properly and when subsequently accessed the contain garbage values. Specifically, the problem occurs with _field1 and _field2 - see the…

geraldCelente
- 1,005
- 2
- 16
- 36
0
votes
2 answers
Java - value of primitive type prior to assignment
What is the value of a primitive type prior to an assignment?
What I'd like to do is have a variable that, if set, returns whatever its set to and if not returns null. I recognise that the below is a stupid way of doing it, and I've already solved…

MrB
- 818
- 8
- 28
0
votes
3 answers
getting a use of unassigned variable error
i am making a program to add a list numbers separated by a comma ( , ) in a text box.
example: 1,12,5,23
in my total += num; i keep getting a use of unassigned local variable with total;
using System;
using System.Collections.Generic;
using…

Aaron Doucet
- 3
- 1
-1
votes
3 answers
Use of unassigned local variable error
I am receiving an error:
"Use of unassigned local variable 'PostData'"
when compiling the following statements below within a method. My intent is take a "string" value containing an XML SOAP header and convert it to a XMLDictionaryWriter object.…

wcfvemi
- 159
- 1
- 4
- 10
-1
votes
2 answers
How to distinguish unassigned variable from zero in Python?
Some external code runs my function of the following code:
def __init__(self,weights=None,threshold=None):
print "weights: ", weights
print "threshold: ", threshold
if weights:
print "weights assigned"
self.weights =…

Dims
- 47,675
- 117
- 331
- 600
-1
votes
2 answers
Use of unassigned variable in switch case in C#
I'm making a basic chat program as a thesis and I've run into this problem.
As you can see on the picture, it gives me an unassigned variable error at line 107, but it works perfectly fine afterwards (like at line 125). The switch case always…

DarkSide
- 19
- 2
-2
votes
1 answer
Use of unassigned variable error when I am trying to assign values to variables using IF statements
I am writing a program in Windows Forms which I am trying to assign values to variables using IF statements depending on which radiobuttons in the form are clicked. I am getting an error "use of unassigned variable" on the lines below in bold. The…

Ninja James
- 11
- 1
-2
votes
2 answers
C# Beginner - "Use of Unassigned Local Variable" Issue
New to C# (only coding for a week so far) trying to create a practice program. Can't seem to get the data I want stored in 'price1' and 'price2'. Error is CS0165 Use of unassigned local variable 'price1' and 'price2'.
I've tried moving lines of code…

TheXoy
- 3
- 2
-2
votes
1 answer
error in the code of C#
while (rdr.Read())
{
imgno = rdr.GetString(0);
}
HttpContext.Current.Response.Write(imgno);
This code generate the error
(Error 5 Use of unassigned local variable 'imgno')
-2
votes
1 answer
Apparently my variable is unassigned?
public Grid (int width, int height, char defaultCharacter) {
for (int n = 0; n <= height; n++) {
List aRow;
for (int i = 0; i <= width; i++) {
aRow.Add(defaultCharacter);
}
this.grid.Add(aRow);
…

ZacG
- 97
- 9
-2
votes
2 answers
What did I do wrong here? The only error I get is near the bottom. Use of unassigned local variable 'parts' right after "add tax"
private decimal TaxCharges()
{
decimal addTax;
decimal parts;
addTax = parts * 0.06m;
taxTxtBx.Text = addTax.ToString("c");
return addTax;
}
unassigned local variable 'parts' right after "addTax =…

Alan Mederos
- 61
- 1
- 4
-2
votes
2 answers
Stuck in function and booleans
I have function called firstRun(), inside of it I have two defined booleans filesDeleted and dirsDeleted.
Also inside in function I have if (filesDeleted == true && dirsDeleted == true) {
When I try to debug application I get error - Use of…

user2713690
- 1
- 5
-3
votes
1 answer
Python says "UnboundLocalError: local variable 'key' referenced before assignment"
i understand that this error happens when a variable gets mentioned before its defined but "key" is assigned to its value. I started learning python a week ago so i am sorry if my question has a really simple answer.
the code:
from stat import…

oas333
- 101
- 1
- 1
- 10