变量的定义统计学_变量的定义

变量的定义统计学

A variable is a way of referring to a storage area in a computer program. This memory location holds values—numbers, text or more complicated types of data like payroll records.

变量是在计算机程序中引用存储区的一种方式。 此存储位置保存值-数字,文本或更复杂的数据类型,例如工资记录。

Operating systems load programs into different parts of the computer's memory so there is no way of knowing exactly which memory location holds a particular variable before the program is run. When a variable is assigned a symbolic name like "employee_payroll_id," the compiler or interpreter can work out where to store the variable in memory.

操作系统将程序加载到计算机内存的不同部分,因此无法在运行程序之前确切知道哪个内存位置保存了特定变量 。 为变量分配符号名称后,例如“ employee_payroll_id”, 编译器解释器可以计算出变量在内存中的存储位置。

变量类型 ( Variable Types )

When you declare a variable in a program, you specify its type, which can be chosen from integral, floating point, decimal, boolean or nullable types. The type tells the compiler how to handle the variable and check for type errors. The type also determines the position and size of the variable's memory, the range of values that it can store and the operations that can be applied to the variable. A few basic variable types include:

在程序中声明变量时,可以指定其类型,可以从整数,浮点型,十进制,布尔型或可为空的类型中选择。 类型告诉编译器如何处理变量并检查类型错误。 该类型还确定变量的内存位置和大小,它可以存储的值的范围以及可以应用于该变量的操作。 一些基本的变量类型包括:

int - Int is short for "integer." It is used to define numeric variables holding whole numbers. Only negative and positive whole numbers can be stored in int variables. 

int - Int是“整数”的缩写。 它用于定义包含整数的数字变量。 只能将负整数和正整数存储在int变量中。

null - A nullable int has the same range of values as int, but it can store null in addition to whole numbers.

-可空INT具有相同的值范围为int,但是它可以存储空除了整数。

char - A char type consists of Unicode characters—the letters that represent most of the written languages. 

char -char类型由Unicode字符(代表大多数书面语言的字母)组成。

bool - A bool is a fundamental variable type that can take only two values: 1 and 0, which correspond to true and false. 

bool- bool是基本变量类型,只能采用两个值:1和0,分别对应于true和false。

float, double and decimal - these three types of variables handle whole numbers, numbers with decimals and fractions. The difference between the three lies in the range of values. For example, double is twice the size of float, and it accommodates more digits.

float ,double和十进制-这三种类型的变量处理整数,带小数和小数的数字。 两者之间的区别在于值的范围。 例如,double是float大小的两倍,并且可以容纳更多数字。

声明变量 ( Declaring Variables )

Before you can use a variable, you have to declare it, which means you have to assign it a name and a type. After you declare a variable, you can use it to store the type of data you declared it to hold. If you try to use a variable that hasn't been declared, your code won't compile. Declaring a variable in C# takes the form:

在使用变量之前,必须先对其进行声明,这意味着必须为其分配名称和类型。 声明变量后,可以使用它存储声明要保存的数据类型。 如果您尝试使用尚未声明的变量,则您的代码将无法编译。 在C#中声明变量的形式为:

<data_type> <variable_list>;

<数据类型> <变量列表>;

The variable list consists of one or more identifier names separated by commas. For example:

变量列表由一个或多个用逗号分隔的标识符名称组成。 例如:

 int i, j, k;

int i,j,k;

 char c, ch;

字符c,ch;

初始化变量 ( Initializing Variables )

Variables are assigned a value using an equal sign followed by a constant. The form is:

使用等号后跟常量的变量被赋值。 形式是:

<data_type> <variable_name> = value;

<数据类型> <变量名称> =值;

You can assign a value to a variable at the same time you declare it or at a later time. For example:

您可以在声明变量的同时或之后为变量赋值。 例如:

 int i = 100;

我= 100;

 or

要么

 short a;int b;double c;

短a; int b;双c;

 /*actual initialization */a = 10;b = 20;c = a + b;

/ *实际初始化* / a = 10; b = 20; c = a + b;

关于C# ( About C#  )

C# is an object-oriented language that does not use any global variables. Although it could be compiled, it is almost always used in combination with the .NET framework, therefore applications written in C# are run on computers with .NET installed.

C#是一种不使用任何全局变量的面向对象的语言。 尽管可以编译,但几乎总是将它与.NET框架结合使用,因此,用C#编写的应用程序可以在装有.NET的计算机上运行。

翻译自: https://www.thoughtco.com/definition-of-variable-958320

变量的定义统计学

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值