new operator returning null - C#

Viewed 934

I have this code:

public ObjectModel.Path GetPath(int pathid)
{
    var path = this.DbContext.Paths.Find(pathid);
    var app = GetApplicationById(path.ApplicationId.GetValueOrDefault());

    var p = new Path 
    {
        ApplicationId = path.ApplicationId,
        Id = path.Id, Password = path.Password,
        UserName = path.UserName,
        LocalUrl = string.IsNullOrEmpty(path.LocalUrl) ? null : System.IO.Path.Combine(path.LocalUrl, app.Name)

    };


    return p;
}  

The variable p is always null. How is this posible?

Here is a print screen of what I am talking about:

enter image description here

I also try with immediate windows I got this:

enter image description here

p CANNOT BE NULL since im creating a new instance of it while all of its properties are not null. I tried clean the project, restart windows, open visual studio as administrator and nothing happened.

Any idea why?

The application is running on .net 4.0, visual studio 2017 v15.2(26430.13) relase.

1 Answers

Your variable is not null.

Debugger by default try to display content of ToString() method when it's overloaded. In this case it's displaying (propably) Uri or FtpUrl value which is null.

Try to click little triangle on your variable when you hover it then you will see full contents of the variable.

Related