首页 > 其他分享 >199 Tuple Class

199 Tuple Class

时间:2024-08-01 19:26:11浏览次数:8  
标签:199 Tuple tuple Console Sample person new Class

示例

Program.cs

using System;

namespace TupleExample
{
    class Sample
    {
        public Tuple<string, int> GetPersonDetails()
        {
            //create a new Tuple that stores person name and age
            Tuple<string, int> tuple = new Tuple<string, int>("Scott", 20);

            return tuple;
        }
    }
    class Program
    {
        static void Main()
        {
            Sample s = new Sample();
            Tuple<string, int> person = s.GetPersonDetails();

            //access values from tuple
            Console.WriteLine(person.Item1); //Scott
            Console.WriteLine(person.Item2); //20
            
            Console.ReadKey();
        }
    }
}

标签:199,Tuple,tuple,Console,Sample,person,new,Class
From: https://blog.csdn.net/KevinHuang2088/article/details/140855415

相关文章

  • 200 Value Tuples
    示例安装NuGet包NuGet\Install-Package System.ValueTuple -Version 4.5.0Program.csusingSystem;usingClassLibrary1;namespaceValueTupleExample{publicclassCustomer{public(intcustomerID,stringcustomerName,stringemail)GetC......
  • CF1997F Chips on a Line 题解
    注意到操作是可逆的,可以先把所有筹码移动到位置\(1\),再进行若干次操作使筹码数量最小化。那么我们只需要对每一个\(i\)知道有多少种情况把筹码全移动到位置\(1\)后恰好有\(i\)个筹码,和这类情况的最少筹码数。记\(f_i\)表示斐波那契数列的第\(i\)项,显然一个位置\(i\)......
  • [USACO1.5] [IOI1994]数字三角形 Number Triangles
    传送锚点[P1216USACO1.5][IOI1994]数字三角形NumberTriangles-洛谷|计算机科学教育新生态(luogu.com.cn)题目[USACO1.5][IOI1994]数字三角形NumberTriangles题目描述观察下面的数字金字塔。写一个程序来查找从最高点到底部任意处结束的路径,使路径经过数字的和最......
  • 零件形式的 CLASS 接口式开发
    装载类类中包含仓库接口类装载在装在类中,指针模式获取(指针不慢,new开辟内存慢)把类放堆上初始化时候new实时计算类网络通信接收发送数据时主线程等待会等网走完的,画图是实时的,网是放在新线程里面双核处理器会两个核心交替处理任务管理器中显示的每一个线程那个句柄是进程......
  • Python - Built-in Exceptions: Python Exceptions Class Hierarchy
     Figure20.4:Built-inexceptionsTheclassBaseExceptionisthebaseclassofallthebuilt-inexceptionclasses.FromBaseException,fourclassesnamedException,SystemExit,KeyboardInterruptandGeneratorExitarederived.Alltheremainingbuilt-in......
  • CF1995C Squaring 题解
    思路详解:请注意,本题解用到了非整数计算,也就是说性能可能不如整数运算,但是易于实现,追求最优解的大佬不建议观看本题解。这个题看似简单,但是由于涉及到了平方操作,不用高精度根本存不下,然后如果你要用高精度的话又会T......
  • Python - Class Decorators
    Wehaveusedfunctionstodecoratefunctionsandtodecorateclasses.Now,wewillseehowtodefineaclassasadecorator.Atthestartofthischapter,inthedefinitionofdecorator,wehadseenthatadecoratorisacallable;acallableisanyobject......
  • Python - Decorating classes
    Whenwetalkaboutdecoratingclasses,wecaneitherdecorateindividualmethodsorwecancreateadecoratortodecoratethewholeclass.classMyClass:def__init__(self,a):self.a=a@timerdefmethod1(self,x,y):print......
  • CF1997(edu168)题解 A-F
    A.StrongPassword注意到最大效果是在两个相同字符之间插入一个不同的,贡献为3。否则在一开始插入一个和首位不同的,贡献为2。#include<bits/stdc++.h>usingnamespacestd;typedeflonglongll;voidsolve(){strings;cin>>s;boolok=0;for(inti......
  • IDEA 字节码工具 jclasslib bytecode viewer
    IDEA字节码工具jclasslibbytecodeviewer 1.下载安装 首先我们在IDEA的插件市场中搜索jclasslibbytecodeviewer和进行下载安装,安装过后根据IDEA版本的不同,可能需要重启才能使用。   2.使用 下载安装过后,在我们的项目中,首先先将整个项目进行编译,编译的......