博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
第二节:Web前端-ASP.NET之C#基础
阅读量:7116 次
发布时间:2019-06-28

本文共 3853 字,大约阅读时间需要 12 分钟。

第二节:Web前端-ASP.NETC#基础

学习ASP.NET,要掌握学习语言,控件等技能,

复制代码

c#编程指令操作对象:

基本概念: 关键字:

class const continue double decimaldefault delegate else enum eventexplicit extern false finally gixedfloat for foreach goto iflock long namespace new nullobject operator out override paramsprivate protected public readonly refreturn sbyte Sealed short sizeofstackalloc static string struct switchthis throw true try typeofuint ulong unchecked unsafe ushort using virtual void volatile whileabstract as base bool breakbyte case catch char checked复制代码

ascii码表:

代码 字符
32 空格
33 !
34 "
35 #
36 $
37 %
38 &
39 '
40 (
41 )
... ...

数据类型:

字符串型:string 整型: int

语法规则

protected void Button_Click(object sender, EventArgs e) { int a,b,c; double C; // 赋值 a = 1; b = 2; c = 3; c = a + b + c; C = a + b + c;  Respense.Write(C);}protected void Button_Click(object sender, EventArgs e){ int age = 12; double weight, height; weight = 12.1; height = 13.1; WriteContent(age, weight, height);}复制代码

数组类型

数据类型分 引用类型和值类型

值类型:分 枚举类型,结构类型,简单类型

简单类型: 整数类型,实数类型,字符类型,布尔类型

字符串类型的变量:string 整型int 32位 短整型short 16位 双精度double d 单精度float f 布尔型boolean 日期时间dateTime

protected void Button_Click(object sender, EventArgs e) { string a = "12"; string b = "123"; Response.Write(a+b); Response.Write("
"); // 换行 int i_a; int i_b; i_a = Convert.ToInt16(a); i_b = Convert.ToInt16(b); Response.Write((i_a+i_b).ToString()); Response.Write("
"); // 换行 char char_a; char_a = Convert.ToChar(65); Respense.Write(char_a);}复制代码

数组

// 数组的定义与应用protected void Button_Click(object sender, EventArg e) { // 数组的定义 int[] a; // 声明一个int型的一维数组 a = new int[5]; // 或者 int[] a = new int[5]; a[1] = 1; a[2] = 2; Response.Write(a[1].ToString()); Response.Write(a[2].ToString()); int[] b = new int[] {1,2,3,4};}复制代码
double  a;a = new double[4] { 23.23, 12.12, 12.34 };string[] str_a = new String[4];str_a[0] = a[0].ToString();str_a[1] = a[1].ToString();str_a[2] = a[2].ToString();Response.Write(str_a[0]);Response.Write(str_a[1]);Response.Write(str_a[2]);复制代码

数组类型转换:

数据类型的默认值 字符串型数组的默认值为:null 而不是""

运算符和表达式

表达式分类: 赋值表达式,运算表达式,方法表达式。

运算符:

算数运算符>逻辑运算符>关系运算符>赋值运算符

x = a++ +b +c;// x = a+b+c; a = a+1;x = ++a +b +c;// a=a+1; x=a+b+c;复制代码

关系运算符

>, <, >=, <=, ==, !=, &&, ||复制代码

程序流程分类:

if语句和switch语句:

break; continue; return;

循环: while,do-while,for

if选择语句:

通过条件表达式-》执行语句 通过条件表达式-》执行语句1或执行语句2

if(条件表达式){ 表达式成立,执行语句; }else { 表达式成立,执行语句;}复制代码
复制代码

水仙花数

一个三位数其各位数字的立方和等于该数本身

public class Demo {  public static void main(String[] args) {    int count = 0;    //定义水仙花数的个数    for(int i=100;i<=10000;i++){       int b = i/100;    //取得百位数      int s = (i-100*b)/10;    //取得十位数      int g = (i-s*10-b*100);    //取得个位数             if(i==g*g*g+s*s*s+b*b*b){ //水仙花数判定        System.out.print(i+" ");  //输出符合条件的数        count++;      }    }    System.out.println("总共有"+count+"个");    }}复制代码

水仙花数指一个N位正整数(N>=3),它的每个位上的数字的N次幂之和等于它本身。

三个数从小到大排序

if(a>b)    /*如果a大于b,借助中间变量t实现a与b值的互换*/    {        t = a;        a = b;        b = t;    }    if(a>c)    /*如果a大于c,借助中间变景t实现a与c值的互换*/    {        t = a;        a = c;        c = t;    }    if(b>c)    /*如果b大于c,借助中间变量t实现b与c值的互换*/    {        t = b;        b = c;        c = t;    }复制代码

猴子吃桃问题

定义 day、x1、x2 为基本整型 第 10 天早上,只剩下一个桃子

int day,x1,x2;     day=9;    x2=1;    while(day>0)    {        x1=(x2+1)*2;    /*第一天的桃子数是第二天桃子数加1后的2倍*/        x2=x1;        day--;    /*因为从后向前推所以天数递减*/    }复制代码

while循环可以0次循环,do-while循环至少会被执行一次循环。

for(计算表达式1;条件表达式;计算表达式2){ // 执行语句}复制代码

continue:跳出当前循环,执行下一次循环

冒泡排序法

10 个数按照从小到大的顺序进行排序

从左到右开始,第一个和第二个进行比较,大的那个就被挑出来,与第三个进行比较,接下来就是依次按照这个方法比较

for(int num=1;num
arr[index+1]){ int temp = arr[index]; arr[index] = arr[index+1]; arr[index+1] = temp; } } } 复制代码

结言

好了,欢迎在留言区留言,与大家分享你的经验和心得。

感谢你学习今天的内容,如果你觉得这篇文章对你有帮助的话,也欢迎把它分享给更多的朋友,感谢。

作者简介

达叔,理工男,简书作者&全栈工程师,感性理性兼备的写作者,个人独立开发者,我相信你也可以!阅读他的文章,会上瘾!,帮你成为更好的自己。长按下方二维码可关注,欢迎分享,置顶尤佳。

转载地址:http://yczel.baihongyu.com/

你可能感兴趣的文章
Ambari 增加新的stack示例
查看>>
我的友情链接
查看>>
信息提示框:MessageBox
查看>>
教你用报表工具搭建企业考核系统
查看>>
321android浏览器
查看>>
find命令基本用法及练习
查看>>
ejabberd disable_sasl_mechanisms
查看>>
什么时候才能恢复我学习的心...
查看>>
Android零基础入门第12节:熟悉Android Studio界面,开始装逼卖萌
查看>>
export, import 和 export default的区别
查看>>
云场景实践研究第5期:朗新科技
查看>>
临近春节你为什么打不到车?概率论来帮忙!
查看>>
MySQL数据库基础操作
查看>>
C++模板别名的理解
查看>>
Elasticsearch在Hdfs上build的实现及优化
查看>>
1.02-字母数字生成器
查看>>
【git搭建】创建本地仓库与github(远程仓库)的传输
查看>>
js中的事件委托或是事件代理详解
查看>>
java设计模式-----原型模式
查看>>
10.13 netfilter5表5链介绍
查看>>