Barney Chambers Barney Chambers -4 years ago 85
C# Question

Xamarin C# - Named argument specifications must appear after all fixed arguments

I am creating an application using Xamarin forms, and have imported the SKCanvas nuget package to allow drawing capability. On their documentation here it is specified that the below code is how you obtain a canvas.

using (var surface = SKSurface.Create(width: 640, height: 480, SKImageInfo.PlatformColorType, SKAlphaType.Premul))
{
SKCanvas myCanvas = surface.Canvas;
}


I am getting an error when I write this code,
Named argument specifications must appear after all fixed arguments have been specified


I have seen a couple of questions similar to mine on here, but none of them apply directly to my problem

Answer Source

You can:

Either put the name to all the parameters:

using (var surface = SKSurface.Create (width: 640, height: 480, colorType: SKImageInfo.PlatformColorType, alphaType: SKAlphaType.Premul)) {
    SKCanvas myCanvas = surface.Canvas;

    // Your drawing code goes here.
}

Or remove the name from the first two (width and height):

using (var surface = SKSurface.Create (640, 480, SKImageInfo.PlatformColorType, SKAlphaType.Premul)) {
    SKCanvas myCanvas = surface.Canvas;

    // Your drawing code goes here.
}

Hope this helps.-

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download