110,561
社区成员
发帖
与我相关
我的任务
分享
enum Student
{
Name, Grade, Class
};
static void Main(string[] args)
{
Console.WriteLine(Student.Name); //Name
Console.WriteLine(Student.Grade | Student.Class); //3
Console.WriteLine(Student.Grade | Student.Name); //Grade
var 线索1 = 人物1 + 时间 + 地点 + 动机1 + 物品1;
var 线索2 = 人物2 + 时间 + 地点 + 动机2 + 物品2;
var 线索3 = 人物3 + 时间 + 地点 + 动机3 + 物品3;
var gate = 线索1 + 线索2 => 线索3;
用简洁的普通文案人员就懂的符号来编写程序,而不是写一大堆只有程序员才关心的程序符号。
所以,运算符重载技术非常重要。using System;
using System.Linq;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
var result = new A { S = "张三" } | new B { N = 5 };
Console.WriteLine($"result.S 结果是 {result.S}");
Console.WriteLine(".......按任意键退出");
Console.ReadKey();
}
}
public class A
{
public string S;
}
public class B
{
public int N;
public static A operator |(A a, B b)
{
return new A { S = a.S + b.N.ToString() };
}
}
}
然后,把鼠标放到竖线那里,可以看到 vs 的切当的提示。然后点击鼠标右键,选择"查看定义“,你就能转到源代码文件去看了。
要学会使用 vs。