C#学习笔记01
来源:互联网 发布:windows窗口概念 编辑:程序博客网 时间:2024/06/10 03:17
早在9月底的时候就准备开始学C#,看了些楚广明的视频教程,觉得还不错吧,国庆到广州玩了几天回学校就要开始准备10月底也就是前几天的考试,也就暂时把C#这个学习任务给放下了,今天开始速攻!
我是个初学者,所以有些错误很正常,欢迎大家指正,希望能帮到同样跟我一起刚开始学习C#的人。以下进入正题:
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("something show here~");
- }
- }
- }
这段代码发挥出他功能的代码只要看 Console.WriteLine("something show here~");,正如英文字面意思,console.WriteLine();代码是用来输出功能的。类似于ASP中的response,JSP,JAVA,C等的print功能一样,很容易理解。
第二个建的是windows窗口的程序,只是让大家看看VS编写这类程序比JAVA编写的异同之处,方便很多的说。
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- MessageBox.Show("您的计算机正处于危险中!!");
- }
- }
- }
首先请大家无视"您的计算机正处于危险中!!这几个字....调试后会出现刚才制作的一个窗口,点击窗口中的按钮时会弹出窗口并显示上面的中文,比JAVA来说方便不少。
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Chapter01
- {
- class Program
- {
- static void Main(string[] args)
- {
- int myInteger;
- string myString;
- myInteger = 17;
- myString = "/"myInteger/"is";
- Console.WriteLine("{0}{1}", myString, myInteger);
- }
- }
- }
这里要注意下myString = "/"myInteger/"is";中的/" 是用来表示“" ”的,因为如果直接用"会出现编译错误,后面的Console.WriteLine("{0}{1}", myString, myInteger);就相当于C中的print(%d,a);这种赋值吧。
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Yunsuan
- {
- class Program
- {
- static void Main(string[] args)
- {
- double firstNum, secondNum;
- string userName;
- Console.WriteLine("Enter your name please");
- userName = Console.ReadLine();
- Console.WriteLine("Welcome {0}",userName);
- Console.WriteLine("Now enter a number:");
- firstNum = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("Now give another number:");
- secondNum = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("the sum of {0} and {1} is {2}",firstNum,secondNum,firstNum+secondNum);//加法
- Console.WriteLine("the result of subtracting {0} and {1} is {2}",firstNum,secondNum,firstNum-secondNum);//减法
- Console.WriteLine("the product of {0} and {1} is {2}",firstNum,secondNum,firstNum*secondNum);//乘法
- Console.WriteLine("the dividing of {0} and {1} is {2}", firstNum, secondNum, firstNum / secondNum);
- Console.WriteLine("the remainder of {0} and {1} is {2}",firstNum,secondNum,firstNum%secondNum);
- }
- }
- }
最后一段代码看似复杂很多,但认真看的话还是比较简单的,拆开来就只有三步:
1.输入你的姓名
2.任意输入一个数
3.任意再输入一个数
4.分别计算加,减,乘,除,取余运算
今天就学了些最最基本的,现在继续看书,今天或者明天继续更新本文或开新贴更新。
- C#学习笔记01
- C# 学习笔记 (Assembly)-01
- C#学习笔记:01背包
- C#学习笔记 ----C#变量
- C#学习笔记 08/01/18
- 黑马程序员-C#基础知识-学习笔记01
- C#学习笔记01:基本数据类型
- C#入门到精通学习笔记01
- C#学习笔记01——SqlBulkCopy
- c#学习笔记(1)
- C#学习笔记
- C# 学习笔记
- C#学习笔记(一)
- C#学习笔记(二)
- C#学习笔记(三)
- c#学习笔记
- C#学习笔记
- C#学习笔记
- mongrel 命令
- 又仔细看了下bootsect.s
- 一些配置小CASE
- meta标签
- 距离
- C#学习笔记01
- 换工作如何加薪
- 时间
- 小结一下
- XNA Game Studio 3.0 已经Final,我准备回归游戏
- 网络营销与策划实践考试试题(一)
- ASP.NET MVC Beta Released
- 研究:漂亮女候选人更易赢得选票
- 泛型类引用有参数的构造函数方法