Skip to content

Add explicit nint cast operator to PWSTR. #1660

@mjr4077au

Description

@mjr4077au

Is your feature request related to a problem? Please describe.

It's common to need to work with the underlying pointer.

Describe the solution you'd like

public static explicit operator nint(PWSTR pwstr)
{
    unsafe
    {
        return (nint)pwstr.Value;
    }
}

Describe alternatives you've considered

I can add an extension method for this, but I can't add extension operators. This means i can't use a natural cast like I can with other pointed to types.

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions