"dim a = b".这是什么类型的声明?如何在c#中使用它? [英] "Dim a=b". What type of declaration is this? How can it be used in c#?
本文介绍了"dim a = b".这是什么类型的声明?如何在c#中使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
"Dim a=b"
.
这是什么类型的声明?
"Dim a=b"
.
What type of declaration is this? How can it be used in c#?
推荐答案
它不能在c#中使用,它是VB代码行. 它所做的是声明一个新变量a
并为其分配值b
.由于VB的类型不安全,因此它不会影响a或b是什么类型.
C#是类型安全的.您可以找到的最接近的是:
It can''t be used in c#, it is a VB code line.
What it does is declare a new variablea
and assign it the value ofb
. Since VB is not type safe, it doesn''t car what type a or b are.
C# is type safe. The closest you can get to this are:
dynamic a = b;
或
var a=b;
但是首先要使用正确的数据类型声明a
更好,这要取决于b
的数据类型. >
But it is much, much better to declare a
using the correct datatype in the first place, depending on what the datatype of b
could be.:
int a = b;
Button a = b;
Control a = b;
声明并分配a
的存储空间.未指定a
的数据类型,a
用变量b
的值初始化(请参见 [ ^ ]),以了解如何将数据类型分配给a
(取决于编译器选项).
我不是专家,但我认为最接近的C#
陈述是
Declares and allocates storage space fora
. Data type ofa
is not specified,a
is initialized with the value of the variableb
(see the documentation at MSDN, "Default Data Types and Values" section[^]) for understanding how a datatype is assigned toa
(it depends on compiler options).
I''m not an expert, but I think the closestC#
statement is
var a = b;
这篇关于"dim a = b".这是什么类型的声明?如何在c#中使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文