CLI/C++;类似于C#(.Net Framework 4.7)中的命名ValueTuple
在CLI/C++中,是否有任何方法可以实现以下目标:CLI/C++;类似于C#(.Net Framework 4.7)中的命名ValueTuple,c#,.net,c++-cli,valuetuple,C#,.net,C++ Cli,Valuetuple,在CLI/C++中,是否有任何方法可以实现以下目标: namespace Test { static class TestClass { static (int a, int b) test = (1, 0); static void v() { var a = test.a; var b = test.b; _ = (a, b); } } } 那么,有没有办法在CLI/C++中创建一个名为Item1和Item2以外的ValueTuple,以便在C#中使
namespace Test
{
static class TestClass
{
static (int a, int b) test = (1, 0);
static void v()
{
var a = test.a;
var b = test.b;
_ = (a, b);
}
}
}
那么,有没有办法在CLI/C++中创建一个名为Item1和Item2以外的ValueTuple,以便在C#中使用。
我使用的是.Net Framework 4.7。值的名称不属于
ValueTuple
名称由编译器维护,属性在需要与外部代码通信时添加
请在上查看
这:
将转化为:
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
namespace Test
{
internal static class TestClass
{
[TupleElementNames(new string[] {
"a",
"b"
})]
private static ValueTuple<int, int> test = new ValueTuple<int, int>(1, 0);
private static void v()
{
int item2 = test.Item1;
int item = test.Item2;
}
}
}
使用系统;
使用系统诊断;
运用系统反思;
使用System.Runtime.CompilerServices;
使用系统安全;
使用System.Security.Permissions;
名称空间测试
{
内部静态类TestClass
{
[TupleElementNames(新字符串[]]{
“a”,
“b”
})]
私有静态ValueTuple测试=新的ValueTuple(1,0);
私有静态void v()
{
int item2=test.Item1;
int item=test.Item2;
}
}
}
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
namespace Test
{
internal static class TestClass
{
[TupleElementNames(new string[] {
"a",
"b"
})]
private static ValueTuple<int, int> test = new ValueTuple<int, int>(1, 0);
private static void v()
{
int item2 = test.Item1;
int item = test.Item2;
}
}
}