随笔分类 - .NET
摘要:1.第一次加载页面时Page.ispostback是false,当触发该页面的web控件时,产生回发,这时候 该属性会是true,所以要用if(!IsPostback)来判断,只在第一次进入页面时加载数据。2.放在使page_load里的代码只执行一遍3.Page.IsPostBack 属性获取一个值,该值指示该页是否正为响应客户端回发而加载,或者它是否正被首次加载和访问。
阅读全文
摘要:int[]a={1,1,2,3,3,4,5,5};List<int>list=newList<int>();foreach(inttmpina){if(list.Contains(tmp))continue;list.Add(tmp);}int[]array=list.ToArray();for(inti=0;i<array.Length;i++){Console.Write(array[i].ToString()+"");}Console.Read();
阅读全文
摘要:List与数组的相互转换 1.从string[]转List<string> 例如:string[] str={“1”,”2”}; List <string> list=new List<string>(str); 2.从List<string>转string[]例如:List<string> list=new List<string>; String[] str=list.ToArray(); //ViewState["idlist"]转换成List<>List<int> idl
阅读全文
摘要:///系统引用using System.Data;using System.Data.OleDb;using System.Data.SqlClient;/// <summary>/// 必需的设计器变量。/// </summary>private System.ComponentModel.Container components = null;private System.Data.DataSet myDataSet;c#本地MDB数据库连接private void menuItem2_Click(object sender, System.EventArgs e)
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication4{ class Class1 { int count; int[] list=new int[50]; public void putin() { Console.Write("请输入你的数组元素,以空格隔开,以回车结束:"); string str = Console.ReadLine(); string[] result = str.Split(
阅读全文
摘要:using System; using System.IO; public class Chapter4 { static void Main() { int[] numbers = new int[100];FileStream f1 = new FileStream(@"c:\numbers.txt",FileMode.Open);StreamWriter s1 = new StreamWriter(f1);Random r1 = new Random(); for (int j = 0; j < 100; j++){ s1.WriteLine( r1.Next(
阅读全文
摘要:System.Diagnostics.Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); // 开始监视代码运行时间 // you code .... stopwatch.Stop(); // 停止监视 TimeSpan timespan = stopwatch.Elapsed; // 获取当前实例测量得出的总时间 double hours = timespan.TotalHours; // 总小时 double minutes = timespan.TotalMinutes; // 总分钟 double seconds = t.
阅读全文

浙公网安备 33010602011771号