VAR"&之间的差异QUOT;和"对象"在C#中

编程入门 行业动态 更新时间:2024-10-24 15:18:18
本文介绍了VAR"&之间的差异QUOT;和"对象"在C#中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是 VAR 键入等同于变在VB?当对象可以接受任何数据类型,是这两个之间的区别?

Is the var type an equivalent to Variant in VB? When object can accept any datatype, what is the difference between those two?

推荐答案

在Visual C#3.0开始,这是在方法范围内声明的变量可以有一个隐式类型 VAR 。一个隐式类型的局部变量是强类型的,就好像你已经自己声明的类型,但是编译器确定的类型。的下面的两个声明我在功能上相当:

Beginning in Visual C# 3.0, variables that are declared at method scope can have an implicit type var. An implicitly typed local variable is strongly typed just as if you had declared the type yourself, but the compiler determines the type. The following two declarations of i are functionally equivalent:

var i = 10; //implicitly typed int i = 10; //explicitly typed

VAR是不会反对

您一定要阅读: C#3.0 - 瓦尔是不是对象

You should definitely read this : C# 3.0 - Var Isn't Object

更多推荐

VAR"&之间的差异QUOT;和"对象"在C#中

本文发布于:2023-05-25 10:56:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/226633.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:差异   对象   VAR   QUOT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!