码迷,mamicode.com
首页 > 编程语言 > 详细

语言基础和基本数据类型

时间:2016-05-16 17:41:50      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:

语言基础

打开程序,1、sln、2、csproj


Console.Write("内容"); 控制台输出内容,不会换行
Console.WriteLine("内容"); 输出内容,自动换行
Console.ReadLine(); 接收用户输入的内容,回车结束
Console.ReadKey(); 接收用户按下的第一个任意键

 

练习

 

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

namespace 语言基础


{
   class Program
     {
         static void Main(string[] args)
            {
                Console.WriteLine("Hello World");

                Console.ReadLine();

 

             }
       }
}

注释: 自己能看到,计算机看不到的内容
//注释
/* aaaaa aaaaa
aaaa aaa */
注释快捷键: Ctrl + K + C
取消注释快捷键: Ctrl + K + U
快速整理布局快捷键: Ctrl + K + D

注意格式,缩进:
快速缩进快捷键 : Tab
反缩进快捷键: Shift + Tab

 

 

 

数据基础

英文 a=afhiwebn

数字 b=3125215

string 字符串类型,就是用 "" 夹起来的内容,中间可以放任意的文字及符号


//定义变量,就是开辟了一个空间,空间名字叫做a,里面可以放string类型的内容
string a;
//赋值,就是把等号右边的内容,送到左边这个变量所开辟的空间中
a = "aaa,你好,123。!★";

 

 

基本数据类型:
1、值类型:数字类型
   1.整型: 只能放整数的类型,int,long
   2.浮点类型: 级别比整型要高,可以放整型和小数点型,double,decimal
2、布尔型:bool
    只有对错,不能放其它东西,对:true,错:false
3、字符型:char
    最多只能放一个汉字。

引用类型: 只需要记住一个,string字符串类型

练习

请输入姓名:
请输入性别:
请输入年龄:
请输入职位:
我的名字叫xxx,我是xxx的。
我今年xxx岁了,我的职位是xxx。

 

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

namespace 练习
{
   class Program
      {
         static void Main(string[] args)
            {
               Console.Write("请输入姓名:");
               string a = Console.ReadLine();

               Console.Write("请输入性别:");
               string b = Console.ReadLine();

               Console.Write("请输入年龄:");
               string c = Console.ReadLine();
               Console.Write("请输入职位:");
               string d = Console.ReadLine();



              Console.Write("我的名字叫");
              Console.Write(a);

              Console.Write("我的性别是");
              Console.WriteLine(b);

              Console.Write("我的年龄是");
              Console.Write(c);

              Console.Write("我的职位是");
              Console.Write(d);
              Console.ReadLine();
         }
   }
}

 

 

快速改变字体大小:Ctrl+鼠标滚珠

字体和背景色:
工具--》选项--》环境--》字体和颜色--》字体:Consolas,项背景:设置一个颜色

行号:
工具--》选项--》文本编辑器--》C#--》行号 打钩

 

语言基础和基本数据类型

标签:

原文地址:http://www.cnblogs.com/songfengyao/p/5498621.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!