Null returns from method in class project

  • Thread starter Thread starter Andy O'Neill
  • Start date Start date
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.
 
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.
 
Back
Top