[计算机软件及应用]高级程序设计c第八章

[计算机软件及应用]高级程序设计c第八章

ID:40005390

大小:4.22 MB

页数:40页

时间:2019-07-17

[计算机软件及应用]高级程序设计c第八章_第1页
[计算机软件及应用]高级程序设计c第八章_第2页
[计算机软件及应用]高级程序设计c第八章_第3页
[计算机软件及应用]高级程序设计c第八章_第4页
[计算机软件及应用]高级程序设计c第八章_第5页
资源描述:

《[计算机软件及应用]高级程序设计c第八章》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、高级程序设计授课教师:祁长兴C#第八章:常用类2021/8/81常用类Math类1字符串类型2窗体和控件类32021/8/82Math静态字段PIE静态方法整数运算初等函数三角函数Abs():求绝对值Ceiling()求大于等于指定数值的最小整数Floor()求小于或等于指定数值的最大整数Round()对数值进行四舍五入Exp():求e的指数幂Pow()指数函数Log()对数函数Lg10()求以10为底的对数Sqrt()求平方根Sin():求正弦函数Cos()求余弦函数Tan()求正切函数。。。。。。2021/8/83staticvoidMain(str

2、ing[]args){doublea=-1.2;intk=-1,d;doubleb,c;inti;b=Math.Abs(a);Console.WriteLine("Abs(a)={0}",b);d=Math.Abs(k);Console.WriteLine("Abs(k)={0}",d);c=Math.Ceiling(1.2);Console.WriteLine("Ceiling(1.2)={0}",c);c=Math.Floor(1.2);Console.WriteLine("Floor(1.2)={0}",c);c=Math.Round(1.5);C

3、onsole.WriteLine("Round(1.5)={0}",c);c=Math.Round(1.2);Console.WriteLine("Round(1.2)={0}",c);b=Math.Exp(2.1);Console.WriteLine("Exp(2.1)={0}",b);b=Math.Pow(2,3);Console.WriteLine("Pow(2,3)={0}",b);b=Math.Log(10);Console.WriteLine("Log(10)={0}",b);b=Math.Log10(10);Console.WriteLin

4、e("Log10(10)={0}",b);b=Math.Sqrt(9);Console.WriteLine("Sqrt(9)={0}",b);Console.ReadLine();}2021/8/84MathDemoP8-12021/8/85string构造函数与赋值1。直接赋值:strings1=“software”2。构造函数赋值:string(char,int)string(char[])string(char,int,int)2021/8/86staticvoidMain(string[]args){strings1="helloworld!";

5、Console.WriteLine("s1={0}",s1);strings2=newstring('a',5);Console.WriteLine("s2={0}",s2);char[]s3=newchar[]{'m','i','c','r','o','s','o','f','t'};strings4=newstring(s3);strings5=newstring(s3,1,4);Console.WriteLine("s3={0}",s3);Console.WriteLine("s4={0}",s4);Console.WriteLine("s5={0

6、}",s5);Console.ReadLine();}2021/8/87String获取字符stringchar:索引函数stringchar[]:char[]ToChayArray()char[]ToChayArray(intint)//起始位置,复制的长度CopyTo(int,char[],int,int)//起始位置,目标数组,,指定数组起始位置,复制的长度2021/8/88staticvoidMain(string[]args){strings1="Microsoft!";char[]chs1=s1.ToCharArray();char[]c

7、hs2=s1.ToCharArray(5,4);Console.WriteLine(newstring(chs1));Console.WriteLine(newstring(chs2));char[]chs=newchar[20];"Microsoft".CopyTo(0,chs,0,9);"Windows2003".CopyTo(0,chs,10,7);Console.WriteLine(newstring(chs));Console.ReadLine();}2021/8/89字符查找intIndexOf(char)intIndexOf(char,in

8、t)intIndexOf(char,int,int)intLastIndexOf

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。