Home > Backend Development > C#.Net Tutorial > What is the difference between declaration and definition in C#?

What is the difference between declaration and definition in C#?

王林
Release: 2023-08-26 08:37:02
forward
842 people have browsed it

C# 中的声明和定义有什么区别?

Declaration means only declaring the variable and allocating memory, but not setting any value.

But definition means that the variable has been initialized.

The same is true for variables, arrays, collections, etc.

Variables

Declare variables.

int x;
Copy after login

Let's define and assign a value.

x = 10;
Copy after login

Array

Declare an array.

int [] n // declaring
int n= new int[10]; // initializing
Copy after login

Let's assign a value.

n[0] = 100;
n[1] = 200
Copy after login

The above is the detailed content of What is the difference between declaration and definition in C#?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template