简体   繁体   中英

Why can I not use Tuple in C#, Visual studio 2010?

I have the following installed: Visual Studio 2010 Professional, .NET 4.0.30319

In my program i added the using system and collections generic but I can not seem to use Tuple ( Using C# )

Can anyone tell me why ? Thanks

您应该选择框架4或更高版本作为目标框架,因为Tuple是从框架4及更高版本引入的。

This code works here like a charm, just started a new C# console project, .Net 4.0:

using System;

namespace TestTuple
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var mytuple = new Tuple<string, string, DateTime>("Alexander", "Moor", Convert.ToDateTime("12.03.2009"));
            Console.WriteLine("{1},{0} born {2}", mytuple.Item1, mytuple.Item2, mytuple.Item3);
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM