C# 中的 typedef 等效项 您所在的位置:网站首页 c中的typedef C# 中的 typedef 等效项

C# 中的 typedef 等效项

#C# 中的 typedef 等效项 | 来源: 网络整理| 查看: 265

C/C++ 中的 typedef 关键字 C# 中的 using 指令 C# 中等效的 typedef 关键字

在本教程中,我们将讨论 C# 中的 typedef 等效关键字。

兔女中国十二生肖 Rw

Please enable JavaScript

兔女中国十二生肖 Rw C/C++ 中的 typedef 关键字

typedef 关键字是 C 和 C++ 编程语言中的保留关键字。typedef 关键字为先前存在的数据类型分配一个新名称。下面的代码示例演示如何在 C++ 中使用 typedef 关键字重命名数据类型。

#include using namespace std; int main(){ typedef unsigned int uint; uint a, b; a = 1; b = 2; cout using System; using System.Collections.Generic; namespace typedef_equivalent_keyword { using ls = List; class Program { static void Main(string[] args) { ls list1 = new ls { "Element 1" }; Console.WriteLine(list1[0]); } } }

输出:

Element 1

我们在 C# 中使用 using 指令将 List 数据类型重命名为 ls。请记住,using 指令的主要目的是允许在我们的代码中使用其他 namespace,并且它与 typedef 关键字一样不起作用。

C# 中等效的 typedef 关键字

在 C# 中没有 typedef 关键字。遗憾的是,没有任何等效于 C# 中 C 和 C++ 编程语言的 typedef 关键字的关键字。解决此问题的唯一真正方法是使用户定义的数据类型名称简短而有意义。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有