Home > other >  Why name does not exist in current context?
Why name does not exist in current context?

Time:12-31

My method

            await ctx.HttpRequestAsync("cancel build", async (http, log) =>
            {
                var response = await http
        .Patch($"{host}/v0.1/apps/{userName}/{appName}/builds/{buildId}")
        .SetXApiTokenHeader(xApiToken)
        .SetCustomHeader("diagnostic-context", diagnosticContext)
        .SetCustomHeader("internal-request-source", internalRequestSource)
        .SendAndReceiveAsJsonAsync<BuildCreateModel>();

Class BuildCreateModel

 public string sourceVersion { get; set; }

But Intelisense shows error

int.TryParse(jsonData.sourceVersion, out sourceVersion)

It says that enter image description here

How to fix this problem?

CodePudding user response:

You can't pass a property as a reference variable.

Rewrite the code to something like this:

if(int.TryParse(jsonData.sourceVersion, out var sv))
{
  sourceVersion = sv;
}
  •  Tags:  
  • c#
  • Related