翻译自 John Demetriou 2019年2月17日 的文章 <C# 8 – Introducing Index Struct And A Brand New Usage For The Hat Operator> 今天我们要讲的是 Hat 运算符(^).目前为止,Hat 运算符(^)已经被用作布尔类型的异或运算符,以及字节.整型类型的按位异或运算符.在 C# 8 中,它有一个新的用法. 这个运算符的新用法是自动创建 Index 结构体的实例.那什么是 Index 结构呢?这在 C# 8
# include <stdio.h> # include <stdlib.h> # include <string.h> # include <malloc.h> //创建一个结构体 typedef struct programmer { int salary; int experience; ]; } Programmer; void OneyearLater(Programmer *); int main () { Programmer p = {,