0

This following works fine:

public value struct Foo {
    Platform::String^ Name; 
    Platform::String^ Type;
};

However, when I tried to add an Platform::Array<double>^ as the following, I will get an error message.

public value struct Foo {
    Platform::String^ Name; 
    Platform::String^ Type;
    const Platform::Array<double>^ Value; 
};

Error message:

signature of public member contains invalid type 'const Platform::Array<double,1> ^

I also tried this const Platform::Array<Platform::String^>^ Values. But I will have similar error message:

signature of public member contains invalid type 'const Platform::Array<Platform::String ^,1> ^'

What does this mean? And how do I fix this?


Edit: Have to use class in this case since value struct can contain as fields only fundamental numeric types, enum classes, or Platform::String^.

public ref class Foo sealed {
    property Platform::String^ Name;
    property Platform::String^ Type;
    property Platform::Array<Platform::String^>^ Values;    
};
Yuchen
  • 30,852
  • 26
  • 164
  • 234

1 Answers1

1

A WinRT value struct (or value class) can only contain primitive types (numbers, strings, etc.) [source]. It cannot contain arrays or reference types (other than IReference<T>).

Thanks to @Yuchen for an edit.

Community
  • 1
  • 1
Peter Torr - MSFT
  • 11,824
  • 3
  • 18
  • 51