Questions tagged [object-reference]

An Object reference is a pointer to an object stored in memory. The main difference is that the object was previously created (via a new operator, for instance) and its reference is kept via an additional variable, that is, its object reference.

An Object reference is a pointer to an object stored in memory. The main difference is that the object was previously created (via a new operator, for instance) and its reference is kept via an additional variable, that is, its object reference.

More Info

325 questions
-2
votes
2 answers

An Object Reference is Required fo Access to Non-Static Member

I apologise, I know this question has been asked a thousand times before by C# beginners (of which I am one), but all the answers I can find say I need to either instantiate the class, or make it static. My class is instantiated, and I am trying to…
Daniel Forsyth
  • 313
  • 2
  • 4
  • 15
-2
votes
2 answers

What happens if i remove an object, which has another object in it that is pointed by an ArrayList

In Java, I have a Class called Couple which has a String and an int as istance variables. And i have an ArrayList which holds istances of Class Couple. A method foo, adds new couples to the ArrayList cop_list. But also, add every message to another…
user3717434
  • 215
  • 4
  • 19
-2
votes
2 answers

PHP arrays not index-able

I am porting C# code to PHP. However, it seems like PHP ignores the array references. The code below gives out the last element 3 times. How can I fix this? class Participants { public $name; public $country; public $town; } class…
-2
votes
1 answer

Cannot access a property or method of a null object reference : as3

. pls help me ... if i debug below code then it is showing Cannot access a property or method of a null object reference ..how to solve it protected function upload_itemClickHandler(event:ItemClickEvent):void { if(upload.selectedValue ==…
thumb
  • 3
  • 2
-2
votes
5 answers

Object reference not set to an instance of an object error using a for loop

private void btnAddStudent_Click(object sender, EventArgs e) { student[counter] = new Student(txtStudentName.Text, txtStudentSurname.Text, int.Parse(txtExamMark.Text), counter); counter++; } private void…
Andre Smith
  • 207
  • 1
  • 6
  • 22
-3
votes
1 answer

How to optimize this c# code?

I have a challenge on a programming platform (CodeWars - "Find the divisors") and my algorithm seems to be too slowly. This is error which I get from platform: Process was terminated. It took longer than 12000ms to complete This is instructions for…
-3
votes
1 answer

c# - Code that HAS NOT RUN YET is causing an exception? How is this even possible?

So I am completely stumped on this one. I am getting an error Object reference not set to an instance of an object. and I am not sure why. I have a class FILE public class FILE { private string _fileName; public string…
Hooplator15
  • 1,540
  • 7
  • 31
  • 58
-3
votes
2 answers

object reference null exception

I'm trying to access the value of resulterr in button clickevent in order to display it in the messagebox. I'm not getting the value inside the button click event despite setting resulterr list as public. I'm getting exception as object reference…
Naraykln
  • 17
  • 7
-3
votes
1 answer

Object reference not set to an instance of an object c# - code posted

I kept trying to play with this code, but am getting, Object reference not set to an instance of an object one the marked arrow. Can anyone look at what I'm doing wrong? I've posted only the relevant code. Thanks! ERROR AT // MY ERROR…
-4
votes
1 answer

Error: “an object reference is required for the non-static field, method or property…”

I have a WPF client programmed with c#. The program is a register demo, you type a name and say if they are here or not and send it to a server and port that is entered into a textbox by the user. When trying to apply this in the code however, I get…
HJagger95
  • 43
  • 1
  • 10
1 2 3
21
22