Null returns from method in class project

A

Andy O'Neill

For a VS2008 web application I added a class library project.
When I use methods on even the simplest class in the class project I get
null returned.
What's up?

blaa....

namespace x
{
public class Damn
{
public string DamnString{ get; set; }

public Damn GetDamn()
{
Damn d = new Damn();
d.DamnString = "Everything in the object is null";
return d
}
}



invoked by something like:

Damn damn = new Damn();
damn.GetDamn();


Whack a break in the line after and damn.DamnString is null.
 
M

Martin Honnen

Andy said:
For a VS2008 web application I added a class library project.
When I use methods on even the simplest class in the class project I get
null returned.
What's up?

blaa....

namespace x
{
public class Damn
{
public string DamnString{ get; set; }

public Damn GetDamn()
{
Damn d = new Damn();
d.DamnString = "Everything in the object is null";
return d
}
}



invoked by something like:

Damn damn = new Damn();
damn.GetDamn();


Whack a break in the line after and damn.DamnString is null.

Well you would need
damn = damn.GetDamn();
to assign the object returned by the GetDamn method call to the variable
named damn.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top