Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7942961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:07:56+00:00 2026-06-04T00:07:56+00:00

I have the following in my WinRT component: public value struct WinRTStruct { int

  • 0

I have the following in my WinRT component:

public value struct WinRTStruct
{
    int x;
    int y;
};

public ref class WinRTComponent sealed
{
    public:
    WinRTComponent();
    int TestPointerParam(WinRTStruct * wintRTStruct);
};

int WinRTComponent::TestPointerParam(WinRTStruct * wintRTStruct)
{
    wintRTStruct->y = wintRTStruct->y + 100;
    return wintRTStruct->x;
}

But, it seems that the value of winRTStruct->y and x are always 0 inside the method, when called from C#:

WinRTComponent comp = new WinRTComponent();
WinRTStruct winRTStruct;
winRTStruct.x = 100;
winRTStruct.y = 200;
comp.TestPointerParam(out winRTStruct);
textBlock8.Text = winRTStruct.y.ToString();

What is the correct way to pass a struct by reference so it an be updated inside the method of a WinRTComponent written in C++/CX?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:07:58+00:00Added an answer on June 4, 2026 at 12:07 am

    You cannot pass a struct by reference. All value types (including structs) in winrt are passed by value. Winrt structs are expected to be relatively small – they’re intended to be used for holding things like Point and Rect.

    In your case, you’ve indicated that the struct is an “out” parameter – an “out” parameter is write-only, its contents are ignored on input and are copied out on return. If you want a structure to be in and out, split it into two parameters – one “in” parameter and another “out” parameter (in/out parameters are not allowed in WinRT because they don’t project to JS the way you expect them to project).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following class public class ButtonChange { private int _buttonState; public void SetButtonState(int
I have following code: public class reader extends Activity { WebView mWebView; String mFilename;
Suppose I have some simple struct like this: public struct WeightedInt { public int
I have following method in wcf webenabled service Public Person AddPerson(Person p); As of
I have following simple class: @interface Article: NSObject { NSString *title; } @property (copy,
I have following setup. from django.db import models from django.contrib.auth.models import User class Event(models.Model):
Have following code: public interface ITest { string St1 { get; } } public
I have following code: typedef int (*t_Function) (int x); t_Function Functions[MAX_FUNCTIONS]; int f(int x)
Have following validation for year value from text input: if (!year.match(new RegExp('\\d{4}'))){ ... }
I have following table Managers (simplified): ID, int Name, nvarchar(100) In a stored procedure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.