三个题解释所有

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FuXIC8
{
class Program
{
static void Main(string[] args)
{
#region 求交集
/*List<int> list1 = new List<int>();
list1.Add(1);
list1.Add(2);
list1.Add(3);
list1.Add(4);
List<int> list2 = new List<int>();
list2.Add(2);
list2.Add(3);
list2.Add(4);
list2.Add(5);
for (int i = 0; i < list1.Count; i++)
{
for (int j = 0; j < list2.Count; j++)
{
if (list1[i] == list2[j])
{
Console.WriteLine(list1[i]);
}
}
}*/
#endregion
#region 遍历输出字典
/*Dictionary<string, string> stu = new Dictionary<string, string>();
stu.Add("001", "张三");
stu.Add("002", "李四");
stu.Add("003", "王二");

//遍历字典的几种方法,还有一种直接取值,这里不做过多演示

foreach (KeyValuePair<string, string> item in stu)
{
Console.WriteLine("学号:{0},姓名:{1}", item.Key, item.Value);
}
foreach (var item in stu)
{
Console.WriteLine("学号:{0},姓名:{1}", item.Key, item.Value);
}
foreach (var item in stu.Keys)
{
Console.WriteLine("学号:{0},姓名:{1}", item, stu[item]);
}
List<string> test = new List<string>(stu.Keys);
for (int i = 0; i < stu.Count; i++)
{
Console.WriteLine("学号:{0},姓名:{1}", test[i], stu[test[i]]);
}*/
#endregion
}
}
#region 定义一个学生类,其有姓名,年龄两个字段,年龄要求不能低于10,不能高于50
class Student
{
public string Name { get; set; }

public int Age;

public int age
{
get
{
return Age;
}
set
{
if (value > 10 && value < 50)
{
Age = value;
}
else
{
throw new Exception("年龄不符合");
}
}
}
}
#endregion
}

最新文章

  1. 【Hawk】高级教程——post参数采集万方医学网论文
  2. Linux 查看服务器开放的端口号
  3. javascript 利用匿名函数对象给你异步回调方法传参数
  4. Android中的Touch事件
  5. get与post
  6. 【最大流】【HDU2883】【kebab】
  7. ZJOI2017 Day3 滚粗记
  8. Java面向对象 异常
  9. Jenkins 配置CI/CD任务
  10. odoo 11 配置nginx反向代理
  11. [转]Emmet使用详解
  12. django无法同步mysql数据库 Error:1064
  13. 人脸检测----Adaboost学习方法
  14. 熬之滴水成石:最想深入了解的内容--windows内核机制(6)
  15. angularjs学习第三天笔记(过滤器第二篇---filter过滤器及其自定义过滤器)
  16. 【读书笔记】iOS-iOS定位
  17. Codeforces 817
  18. Windows Phone Bing lock screen doesn&#39;t change解决方法
  19. Nginx代理
  20. Django 2.0.1 官方文档翻译: 高级教程:如何编写可重用的app (page 13)

热门文章

  1. Core 3.1 MVC 抛异常“InvalidOperationException: No service for type &#39;Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory&#39; has been registered.”
  2. JavaScript之最长回文字符串
  3. Linux 配置mysql 免安装版。
  4. ApacheCN 机器学习译文集 20211111 更新
  5. bom-scroll
  6. linux下格式化json文件数据
  7. Plist存储
  8. 任意文件上传漏洞syr
  9. Ubuntu18修改系统时间
  10. Elasticsearch笔记2