课堂随笔

using System;


namespace text2
{
class Program
{
static void Main(string[] args)

{
int @int = 300; // 数据类型名 变量名 变量赋值
// int a;double b=12.3;a=(int)b;

int _Int;

int a, s, d;
a = 1; s = 2; d = 3;

_Int = 100;


Console.WriteLine("_Int=" + _Int );
_Int = 200;


Console.WriteLine("_Int="+ _Int);
long _Long = _Int;
short _Short = (short)_Int;// 强制转换 从大箱子拿出的东西进行强制转换
short _Short1= Convert.ToInt16(_Int);//用conver进行转换 常用的
int _Int1 = Convert.ToInt32("123");//用字符串转数值
// int _Int=aa(int)"123";
int b = int.Parse("123");//用parse转
long _L = long.Parse("12121212");
float _Float = 123.99F;
double _Double = 1.99;
decimal _D = 1.45M;
_Int = (int)_Float;
// char_Char = 'G'; //字符型用单引号表示字符 int parse 不允许转小数
bool zhen = true;
bool jia = false;//布尔型 条件判断
//日期时间
DateTime dt = DateTime.Now;//当前日期时间

Console.WriteLine("dt等于" + dt.ToString("yyyy:MM:dd: hh:mm:ss"));
Console.WriteLine("dt等于" + dt.ToString("HH时mm分ss秒"));
DateTime Today = DateTime.Today;
Console.WriteLine("true 转换成_Int等于" + true);
Console.WriteLine("false 转换成_Int等于" + false);

Console.WriteLine("请输入;");

string read = Console.ReadLine();
Console.Write("您的收入是");
Console.WriteLine(read);


Console.ReadLine( );

原文地址:https://www.cnblogs.com/hanke123/p/4690710.html