C#语言基础知识

一.

string i_str = "321";

string 型,强制转换成 int 型

int i_int1 = int.parse(i_str);

string 型,强制转换成 double 型

double i_dou1 = double.parse(i_str);

二.

string 型 ,转换成 int 型

int i_int2 = convert.ToInt32(i_str);

string 型 ,转换成 double 型

double i_dou2 = convert.ToDouble(i_str);

const double pie = 3.1415926; 

const  修饰符  

可以使用常量,但是不能改变常量。

Console.Write("请输入100以内的数");     输入的第一步格式,写入一个东西

string d = Console.ReadLine();      读出某个东西,返回放在 string 里的 d 的里面

Console.WriteLine(d);        再把这个东西写出来

Console.ReadLine();          然后让它等一等,等待输入

if(x == 1){

Console.WriteLine("yes");

}else if(x == 2){

Console.WriteLine("false");

}

if 的判断语句

三元运算符

int y = ture ? 1:2;

switch(y){

case 1:

     break;

case 2:

     break;

case 3:

     break;

default:

     break;

}

原文地址:https://www.cnblogs.com/yunpeng521/p/6961816.html