《21天学通C#》变量使用前需要声明和赋值,赋值后可以重新赋新的值

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 变量声明赋值使用
{
class Program
{
static void Main(string[] args)
{
//变量使用之前需要声明和赋值
//声明 my_variable
int my_variable;

//赋值给my_variable
my_variable = 5;
Console.WriteLine(" my_variable contains the value {0}", my_variable);

//给my_variable赋一个新的值
my_variable = 100;
Console.WriteLine(" my_variable contains the value {0}", my_variable);

Console.WriteLine("按任意键退出程序!");
Console.ReadKey();
}
}
}

原文地址:https://www.cnblogs.com/nnty/p/9909758.html