Time of Update: 2018-12-06
函數的參數不同叫多態,函數的參數類型可以不確定嗎?函數的傳回值只能是一個嗎?函數的傳回值可以不確定嗎?泛型是一種特殊的類型,它把指定類型的工作延遲到用戶端代碼聲明並執行個體化類或方法的時候進行。下面是兩個經典樣本:1.輸入一個字串,轉化為想要的類型。利用泛型的特性,傳回值可以是指定的類型。2.比較兩個對象,傳回值較大的一個。using System;using System.Collections.Generic;using System.Text;namespace FamilyManage{
Time of Update: 2018-12-06
在asp.net開發中,經常會用到後台和前台的互動,就此總結了一點c#和javascript相互操作的方法 1.在後台c#代碼中調用jacascript的方法 javascript代碼: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><script type="text/javascript" language="javascript"&
Time of Update: 2018-12-06
來自:http://323229113.blog.163.com/blog/static/2185362820081011111255946/利用System.EventHandler來實現兩個表單間的事件調用在.NET中,表單也被定義為一個類,所以要想調用表單中的某個方法,除了要將要調用的方法設為public外,還得建立一個表單類的執行個體。然而,在下面這種情況下,就是當我們開啟了表單1(有了此表單的一個執行個體),接著開啟了表單2,接下來我們想通過觸發表單2中的某個事件來調用表單1中的某個方
Time of Update: 2018-12-06
好久不用XML了。最近做Silverlight項目,需要通過Web Service訪問一些C++的Dll.使用XML傳遞資料。正好複習一下XML操作。大氣象Code highlighting produced by Actipro CodeHighlighter
Time of Update: 2018-12-06
Code highlighting produced by Actipro CodeHighlighter
Time of Update: 2018-12-06
Code highlighting produced by Actipro CodeHighlighter
Time of Update: 2018-12-06
CodeCode highlighting produced by Actipro CodeHighlighter
Time of Update: 2018-12-06
添加引用IrisSkin2.dll建立個檔案夾skin用來儲存皮膚檔案,把需要的皮膚比如MP10.ssk複製到此目錄下。在Form_Load事件裡添加如下代碼:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace
Time of Update: 2018-12-06
聲明這是 微軟論壇上看的. 我看了很多人都在尋找C# mciSendString()迴圈播放音樂學英語重要呀。using System;using System.Runtime.InteropServices;using System.Text;using System.Windows.Forms;namespace PlayMp3WithWindow{ public partial class Form1 : Form { public const int MM_
Time of Update: 2018-12-06
上次研究了一下javascript的四捨五入:http://www.cnblogs.com/greatverve/archive/2010/01/25/1655619.html今天把C#的方法也試了一下,小知識慢慢積累吧,懶了,每天都沒什麼進步了。 代碼 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->//C#:按精度四捨五入string str =
Time of Update: 2018-12-06
網上找了很多方法,都沒有突出重點,著急著用,快速總結一下,把重點部分突出。讀:ws.get_Range("A1", Type.Missing);寫:ws.Cells[1, 1] = "修改的內容";using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;us
Time of Update: 2018-12-06
IT發展至今,字元編碼版本眾多,目前流行的GBK,Unicode,UTF-8編碼與漢字的轉換可用如下代碼: private void button1_Click(object sender, EventArgs e) { //漢字轉為Unicode編碼: string hz = textBox1.Text.ToString(); byte[] b=Encoding.Unicode.GetBytes(hz)
Time of Update: 2018-12-06
List<int> list1 = new List<int>();list1.Add(1);list1.Add(2);list1.Add(3);List<int> list2 = new List<int>();list2.Add(3);list2.Add(4);list2.Add(5);//得到的結果是4,5 即減去了相同的元素。List<int> list3 = list2.Except(list1).ToList();forea
Time of Update: 2018-12-06
foreach (string s in Enum.GetNames(typeof(WallKind))){ WinFormTools.MsgBox(s);}有人問怎樣遍曆Revit API中的枚舉,遍曆枚舉是C#的文法功能。來自MSDN枚舉可用來儲存字串與數位值對,相當於一個對照表常用方法:GetName(),GetValue(),Parse()using System; public class EnumTest { enum Days { Saturday, Sunday,
Time of Update: 2018-12-06
最近我們在工作中碰到一個奇怪的問題,最後確定是多繼承引起的指標漂移,跟C++物件模型有關。示意如下:class A {...};class B{...};class AB : public B, public A {...}...AB *pab = new AB();A* pa = (A*)pab;B* pb =
Time of Update: 2018-12-06
CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include <iostream>public A{public: void f() { std::cout << "A::f()" << std::endl; }};public B : public A{public:
Time of Update: 2018-12-06
VB.NET中還是有很多有用的東西的。比如VB.NET可以直接調用Microsoft.VisualBasic命名空間下的各種有用的函數,特別是一些類型驗證函式(IsDate,IsNumeric)就十分有用。就拿判斷是否為數字來說,在網上我找到了在C#中用到的三種方法(但都有各自的不足之處):1、將字串分解成Char,然後用Char.IsNumber(c)驗證public bool IsNumericChar(string str){ if (str == null || str.Len
Time of Update: 2018-12-06
添加引用“Microsoft ADO Ext. 2.8 for DDL and Security”、“Microsoft ActiveX Data Objects 2.8 Library”static void Main(string[] args) { ADOX.Catalog cat = new ADOX.Catalog(); cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" +
Time of Update: 2018-12-06
做web頁面很多要用到日期輸入,.net內建的日曆控制項每次都需要與伺服器互動很不方便。為了圖省事自己開發了一個web控制項。參照用JavaScript編寫的日期選擇,將其中的JavaScript部分寫入控制項中就可以了。代碼不複雜,拿出來大家共用以下。大家幫忙找找Bug,提提改進意見。實現效果如下: 源碼下載:TestControl.rar TestControl(v1.0.1).rar(解決了會被select遮擋的問題)Bug:控制項放到frame 的頁面裡面使用得時候就會出錯:
Time of Update: 2018-12-06
C#中使用Regex驗證電話號碼、手機號、社會安全號碼、數字和郵編 C#中使用Regex驗證電話號碼、手機號、社會安全號碼、數字和郵編驗證電話號碼的主要代碼如下:public bool IsTelephone(string str_telephone) { return System.Text.RegularExpressions.Regex.IsMatch(str_telephone, @"^(\d{3,4}-)?\d{6,8}$"); }驗