《C#求职宝典》读书笔记
2024-09-01 19:22:28
递归算法运用
一列数的规则如下: 1、1、2、3、5、8、13、21、34...... 求第30位数是多少,
public class MainClass { public staticvoid Main() { Console.WriteLine(Foo()); } public staticint Foo(int i) { if(i <= ) return0; elseif(i > && i <= ) return1; elsereturn Foo(i -) + Foo(i - ); } }
页面上所有TextBox控件并给它赋值为string.Empty
foreach(System.Windows.Forms.Control control in this.Controls) { if(control is System.Windows.Forms.TextBox) { System.Windows.Forms.TextBox tb = (System.Windows.Forms.TextBox)control ; tb.Text= String.Empty ; } }
冒泡排序算法
int [] array =new int ; int temp = ; for (int i = ; i < array.Length - ; i++) { for(int j = i + ; j < array.Length ; j++) { if(array[j] < array[i]) { temp= array[i] ; array[i]= array[j] ; array[j]= temp ; } } }
分析程序输出
1、当使用new B()创建B的实例时,产生什么输出?
using System; class A { publicA() { PrintFields(); } publicvirtual void PrintFields(){} } class B:A { intx=; inty; publicB() { y=-; } publicoverride void PrintFields() { Console.WriteLine("x={0},y={1}",x,y); } }
答:X=1,Y=0;
2、以下代码输出:
using System; class A { public static int X; static A() { X=B.Y+; } } class B { public static int Y=A.X+; static B(){} static void Main() { Console.WriteLine("X={0},Y={1}",A.X,B.Y); } }
答:x=1,y=2
产生一个长度100的int数组,并向其中随机插入1-100,并且不能重复
采用list和循环
int[] intArr=new int[]; ArrayList myList=new ArrayList(); Random rnd=new Random(); while(myList.Count<) { int num=rnd.Next(,); if(!myList.Contains(num)) myList.Add(num); } for(int i=;i<;i++) intArr[i]=(int)myList[i];
最新文章
- require的总结
- android——从零开始
- pdfkit安装使用
- C#的cs文件中Response.Clear();Response.ClearHeaders()的作用
- [Papers]NSE, $\pi$, Lorentz space [Suzuki, NA, 2012]
- 一个js排序
- PHPCMS v9栏目添加字段及描述编辑器修改方法
- wxWidgets Tutorial
- Akka(38): Http:Entityof ByteString-数据传输基础
- Java编程思想阅读收获
- excel冻结标题栏,让标题栏不滚动的方法
- 使用LVM进行分区扩展的记录
- 【转载】ASP.NET生成图片的缩略图
- SolrCloud集群搭建(基于zookeeper)
- 根据设备宽高设置View的大小
- 禁止网站被别人通过iframe引用
- LINUX系统一一CentOS6.5之tomcat安装
- OpenGL笔记(四) API参考
- spring整合redis(jedis)
- the django travel three[form表单验证]