using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
/****值类型****/
bool test;//必须赋值,否则报错
test = true;
Console.WriteLine(test.ToString());//输出的是True;
Boolean test2;//必须赋值,否则报错
test2 = false;
Console.WriteLine(test2.ToString());//输出的False;
int num1;//必须赋值,否则报错
num1 = 2;
Console.WriteLine(num1.ToString());
float num2;
num2 = 3.433F;//不赋值报错,不加F报错
Console.WriteLine(num2.ToString());
double num3;
num3 = 3.43;//必须赋值,否则报错
Console.WriteLine(num3.ToString());
decimal num4;
num4 = 4.3M;//不赋值报错,不加M报错
Console.WriteLine(num4.ToString());
/****引用类型****/
string a;
a = null;
string b = a;
a = "3";
Console.WriteLine(a);//输出3
Console.WriteLine(b);//输出空字符
String str1 = "abc";
String str2 = str1;
str1 = "change";
Console.WriteLine(str1);
Console.WriteLine(str2);
Person p1 = new Person();
Person p2 = p1;
p1.Name = "p1";
Console.WriteLine(p2.Name);//输出p1
p2.Name = "p2";
Console.WriteLine(p1.Name);//输出p2
Console.WriteLine(p2.Name);//输出p2
}
}
}