随笔分类 - C#学习
摘要:1.send: C# codeWebRequest myHttpWebRequest = WebRequest.Create("http://abc.com/xxx.aspx");// Set the 'Method' property of the 'Webrequest' to 'POST'.myHttpWebRequest.Method ="POST";// Create a new string object to POST data to the Url.string postData =@&qu
阅读全文
摘要:方法一 注:需要.net 3.5框架的支持string s = "101,102,103,104,105,101,102,103,104,105,106,107,101,108";s = string.Join(",", s.Split(',').Distinct().ToArray());方法二class Program { static void Main(string[] args) { string result=""; string str = "101,102,103,104,105,101,10
阅读全文
摘要:想在自己的android应用中获得当天的天气情况,这该怎么做呢?不用担心。中国国家气象局提供了获取所在城市天气预报信息接口。通过这个接口,我们就可以获取天气信息了。中国国家气象局天气预报接口总共提供了三个:http://www.weather.com.cn/data/sk/101010100.htmlhttp://www.weather.com.cn/data/cityinfo/101010100.htmlhttp://m.weather.com.cn/data/101010100.html最详细的信息来自第三个接口。上面url中的101010100是城市代码,这里是北京的城市代码。只需要改变
阅读全文
摘要:1。日期格式:月份大写 <%# DateTime.Parse(Eval("buyTime").ToString()).ToString("yyyy-MM-dd")%> 或者 <%# Convert.ToDateTime( Eval("buyTime").ToString()).ToString("yyyy-MM-dd") %>或者gridview中 <asp:BoundField DataField="insertTime" DataFormatString=&qu
阅读全文
摘要:开发过程中我们可能会看到这种代码1 intorderState=3; 2 if(orderState==1){} 3 elseif(orderState==2){} 4 elseif(orderState==3){} 5 else 6 thrownewException("nostatus"); 这些状态可能会因为需求变更增加或者减少,维护很不方便。换了一种写法,感觉好多了。1 publicstringGetStatusName(stringstatus) 2 { 3 string[][]statusTbl={ 4 newstring[]{"1",&qu
阅读全文
摘要:usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingSystem.Collections.Generic;publicpartialclass_Default:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){List<str
阅读全文
摘要:C# POST提交 /// <summary> /// post 网址提交 /// </summary> /// <param name="postUrl">提交网站</param> /// <param name="paramData">参数</param> /// <param name="dataEncode">编码方式</param> /// <returns></returns> public static
阅读全文
摘要:[ASP.NET]新手必讀-Client/Server code的差別 Client端的程式負責什麼?Server端的程式負責什麼?當兩者想要加在一起用的時候又該怎麼寫?在小舖上的ASP.NET討論版上這種問題出現的頻率應該排的上前幾名了,舉以下這個例子來說:我想要在按下某的按鈕後,先執行一段程式,接著跳出一個確認窗讓使用者確認是否繼續執行,我該怎麼寫?1 protected void Button1_Click(object sender, EventArgs e) 2 ...{ 3 //Do something before confirm 4 5 //再動態註冊一個JavaScript詢
阅读全文
摘要:大家用removeat(索引值),删除的时候,索引值会动态变化。大家可以采取从最后循环删除的办法,如:for(int i=a.count;i0;--i){a.removeat(i);}
阅读全文
摘要:前不久在aspx中放了个按钮控件: asp:Button ID="btnSend" runat="server" Text="发 送" OnClientClick="return btnSend();" OnClick="btnSend_Click" /然后又放了一个验证控件(RequiredFieldValidator),突然发现在界面提交时,验证控件失效了。 后来在看页面源文件时才发现,当页面有RequiredFieldValidator时,会对所有button加上CausesValidation="True"的属性 ,这样就会默认在提交时调用ASP.Net自带的Page_Client
阅读全文
摘要:1: // Taipei 101使用 HttpWebRequest、HttpWebResponse 類別: 如果代码查询的蛮足不了你的要求,可以去这里看看http://www.playgoogle.com/googlemap/tool1.html
阅读全文
摘要:UserControl uc= (UserControl) this.LoadControl("WebUserControl1.ascx"); ((Label)uc.FindControl("Label1")).Text= "111"; this.Page.Controls.Add(uc);
阅读全文
摘要:今天在将数据库里的datetime类型数据赋给C#里DateTime类型变量的时候遇到一个问题,那就是数据库里面的datetime数据存在null值。C#默认不能将null赋给DateTime变量,但是可以使用Nullable类型的DateTime,只需在声明变量的时候在DateTime后加一个?号,如:DateTime? x ;x便可以赋null值。但是从数据库的datetime类型变为C#的D...
阅读全文
摘要:要学好LINQ查询语法,就不得不先理解C# 3.0的一些新特性,下面一一简单介绍。隐含类型局部变量var age = 26;var username = "zhuye";var userlist = new [] {"a","b","c"};foreach(var user in userlist)Console.WriteLine(user); 纯粹给懒人用的var关键字,告诉编译器(对于CLR...
阅读全文
摘要:[转]C#实现给图 片加透明度水印 首先我们强调一下opacity的概念,是“不透明度”,它表示的 是两个图层之间的关系,即该属性隶属于本图层,它表示与本图层下面图层之间的像素合成关系,当opacity=100%时,表示本图层完全不透明,因此下 面的像素完全被遮挡。当opacity=0时,表示本图层完全透明,即能看到下面的图层。这是photoshop...
阅读全文
摘要:1.项目的属性里面,要选上“生成XML注释文档”2.生成时是生成dll和xml,别人要引用这个dll,把xml也烤给他,他就能看到dll 的注释了。
阅读全文
摘要:using System; using System.Collections.Generic; using System.Text; using System.Collections; using System.Data; namespace ERPDAL { public interface IDAL { /*-------------- 说明 --------...
阅读全文
摘要:接口就是一个先签协议(接口定义),后实现。 本示例显示声明一个 IDimensions 接口和一个 Box 类,该类显式实现接口成员 Length 和 Width。通过接口实例 myDimensions 访问这些成员。 // explicit1.cs interface IDimensions { float Length(); float Width(); } clas...
阅读全文
摘要://树控件。TreeNode node = new TreeNode(function[i].Function1); treeView1.Nodes.Add(node); for (int j = 0; j < function.Count; j++) { if (function[i].Id == function[j].Uid) { TreeNode nod = new TreeNode...
阅读全文
摘要:一、抽象类: 抽象类是特殊的类,只是不能被实例化;除此以外,具有类的其他特性;重要的是抽象类可以包括抽象方法,这是普通类所不能的。抽象方法只能声明于抽象类中,且不包含任何实现,派生类必须覆盖它们。另外,抽象类可以派生自一个抽象类,可以覆盖基类的抽象方法也可以不覆盖,如果不覆盖,则其派生类必须覆盖它们。 二、接口: 接口是引用类型的,类似于类,和抽象类的相似之处有三点: 1、不能实例化; 2、包含未...
阅读全文
浙公网安备 33010602011771号