How to use List <T> or dictionary <T, T2> in C # WinRT component
I am trying to create a C # WinRT component for use in metro style (win8) applications, and I am having problems with projected types.
It seems that the IVector <> and IMap <> data types are not available due to their level of protection?
My WinMD test library has one class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation.Collections;
namespace ClassLibrary1
{
public sealed class Class1
{
public IVector<string> foo()
{
return new List<string>();
}
}
}
I get the following compiler errors:
Inconsistent accessibility: return type 'Windows.Foundation.Collections.IVector<string>' is less accessible than method 'ClassLibrary1.Class1.foo()'
'Windows.Foundation.Collections.IVector<string>' is inaccessible due to its protection level
What am I doing wrong?
EDIT:
Yeah!
Turns out I shouldn't use WinRT type names directly, but instead use their translated .NET names.
The correct code is as follows:
namespace ClassLibrary1
{
public sealed class Class1
{
public IList<string> foo()
{
return new List<string>();
}
}
}
+5