zoukankan      html  css  js  c++  java
  • c# 7 vs2017 tuple

        var unnamed = (42, "The meaning of life");
        var anonymous = (16, "a perfect square");
        var named = (Answer: 42, Message: "The meaning of life");
        var differentNamed = (SecretConstant: 42, Label: "The meaning of life");

        named = unnamed;

        (int Answer, string Message) named2 = (42, "The meaning of life");
        (int Answer, string Message) differentNamed2 = (42, "The meaning of life");

    下面错误:

        var named3 = (int Answer, string Message)(42, "The meaning of life");
        var differentNamed3 = (int Answer, string Message)(42, "The meaning of life");

    既然(int Answer, string Message)是类型名,(42, "The meaning of life")是变量值,为什么类型名不能放在变量值前面呢?何况类型一致。

    或者Tuple<int Answer, string Message> named4 =(42, "The meaning of life");

    var named5 = Tuple<int Answer, string Message>(42, "The meaning of life");

  • 相关阅读:
    第43周四
    第43周三
    第43周二
    第43周一
    无聊时做什么2
    2014第42周日当无聊时做什么
    第42周六
    第42周五
    Web版的各种聊天工具
    cocos2d_x_06_游戏_一个都不能死
  • 原文地址:https://www.cnblogs.com/xiexiaokui/p/7402032.html
Copyright © 2011-2022 走看看