Time of Update: 2017-01-13
type[] typename=new type[size]; 如int[] a=new int[2];string[] str=new string[5];實事上我們平常是用int[],string[]...的,此時我們已經建立一個Array數組,只不過我們平常沒有這種意識而已.(1):type資料類型不能缺;且要統一,而不能是如 int[] a=new Array[];(2):數組的大小size不能缺,否則c#認為是出錯的,因為數組是一段固定長度的記憶體;(
Time of Update: 2017-01-13
asp教程.net c#中[],List,Array,ArrayList的區別[] 是針對特定類型、固定長度的。List 是針對特定類型、任意長度的。List 類是 ArrayList 類的泛型等效類,某些情況下,用它比用數組和 ArrayList 都方便。我們假設有一組資料,其中每一項資料都是一個結構。public struct Item{ public int Id; public string DisplayText;
Time of Update: 2017-01-13
asp教程.net 正則替換html標籤與刪除指定字元方法,使用了Regex進行規則過濾,由於html標記都是基於<>這種格式,而且還有類似 這樣的符號,所以分了2次處理將字串處理為無html格式的字串。 public string NoHtml(string html){ string StrNohtml = System.Text.RegularExpressions.Regex.Replace(html,
Time of Update: 2017-01-13
首先,測試幾個模組裡分別添加如下幾行:int id = convert.toint32(cbocategory.selectedvalue);messagebox.show(id.tostring());1.在cbocategory_selectedindexchanged() cbocategory_selectedvaluechanged()中添加,編譯無法通過,報錯如下:
Time of Update: 2017-01-13
資料是每一款開發應用程式都會用的,他是一ojb資料類型 哦,下面我們來看看關於.net數組吧,下面來看看一款簡單扼要應用執行個體。using system;using system.collections.generic;using system.text;namespace funwitharrays{class program{ static void main(string[] args) { &
Time of Update: 2017-01-13
代碼如下複製代碼 using System.Reflection;using System.Runtime.CompilerServices;//// 有關程式集的常規資訊是通過下列// 屬性集控制的。更改這些屬性值可修改與程式集// 關聯的資訊。//[assembly: AssemblyTitle("")][assembly: AssemblyDescription("")][assembly:
Time of Update: 2017-01-13
在開發C/S的用戶端時,經常要判斷用戶端與伺服器的資料庫是否已串連,也就是測試連接的功能。簡單的幾行代碼,如下所示:/// <summary> /// 判斷資料庫是否串連 /// </summary> /// <returns>是否串連</returns> public bool IsConnected() { SqlConnection connection = new
Time of Update: 2017-01-13
代碼如下複製代碼 objDocLast = objApp.Documents.Open( ref objOrgDoc, //檔案名稱 ref objMissing, //確認版本 ref objMissing, //唯讀 ref objMissing, //添加到最近的檔案 ref objMissing, //密碼檔案 ref objMissing, //密碼摸板 ref objMissing,
Time of Update: 2017-01-13
1. 一段編譯沒經由過程的代碼 代碼如下複製代碼 int a = int.MaxValue * 2; 以上程式碼片段編譯沒有經由過程,在VS2010中會有一條紅色的波浪線指出這段代碼有題目:”The operation overflows at compile time in checked mode”。這說瞭然編譯器會在編譯時間搜檢數學運算是否溢出。然則編譯時間能搜檢出溢出的景象僅限於應用常量的運算。2中的代碼編譯器就不報不失足誤來了。2.
Time of Update: 2017-01-13
最近在學習中突然想到,我在64位環境下,int取值範圍是否有變化?為了檢測這個結果,我做了以下這個測試:1、環境:win7旗艦版64位+vs2010 sp1(版本號碼:10.0.40219.1SP1Rel)+.Net 4.0.30319 SP1Rel2、代碼: 代碼如下複製代碼 using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace
Time of Update: 2017-01-13
更新應用程式的設定檔之後需重新整理ConfigurationManager.RefreshSection("appSettings");// 重新整理命名節,在下次檢索它時將從磁碟重新讀取它。ConfigurationSettings也存在這個問題, 但是我還不知道怎麼重新整理節點, 呵呵.舊方法: 各位看官最好使用下面”新方法”設定檔: 代碼如下複製代碼 <configuration> <appSettings&
Time of Update: 2017-01-13
經常用string[], int[]這些數組, 今天偶然發現還有一個System.Array類, 它的聲明如下: 代碼如下複製代碼 public abstract class Array : ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable 看來它是一個抽象類別.查一下msdn, 發現它的用途如下:"提供建立、操作、搜尋和排序數組的方法,
Time of Update: 2017-01-13
先來看WinRAR自身的支援調用命令:壓縮命令:a {0} {1} -r 【{0}:壓縮後檔案名稱|{1}:待壓縮的檔案實體路徑】ex:"a 你妹.rar f:\MM -r" (含義為將f盤下MM的檔案夾壓縮為"你妹.rar"檔案)解壓命令:x {0} {1} -y 【{0}:待解壓檔案名稱|{1}:待解壓檔案實體路徑】ex:"
Time of Update: 2017-01-13
於C#中timer類 在C#裡關於定時器類就有3個 1.定義在System.Windows.Forms裡 2.定義在System.Threading.Timer類裡 3.定義在System.Timers.Timer類裡
Time of Update: 2017-01-13
假設有一個string “BaSiC”,需要將它轉變為大小寫,那麼該如何轉換? 最簡單的方式:調用api: 代碼如下複製代碼 string str = "BaSiC"; string strUpper = str.ToUpper();string strLower = str.ToLower();
Time of Update: 2017-01-13
先發服務端的(Server)完整代碼如下:引入命名空間: 代碼如下複製代碼 using System.Net.Sockets; using System.Net; using System.Threading; 完整代碼如下: 代碼如下複製代碼 namespace SocketServer { class Program
Time of Update: 2017-01-13
在c#中有直接表示字串的類型,即string類型,他是char字元的集合,就像是char類型的制度數組.NET Framework支援對字串進行強大的處理功能,如字串的尋找,替換,格式化,調整等字串可以拼接 可以用 + 串連2個字串遍曆字串 可以像數組一樣遍曆字串 代碼如下複製代碼 string theString = "hello,world";char theFristChar = theStringp[0];
Time of Update: 2017-01-13
其實有些時候會犯一些錯誤,就是類名取了一個跟系統類別名雷同的情況,其實這是設計上的失誤,但是會出現一個情況就是沒改了,那麼global關鍵字就起到了作用。如下代碼: 代碼如下複製代碼 using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace globalFunc{ class Program &
Time of Update: 2017-01-13
new()解釋說到是where字句的建構函式約束,帶有new()約束的任何類型都必須有可訪問的無參建構函式,正常來說C#建立的類預設都有一個無參的建構函式,即使你沒有寫,但是如果你寫了一個有參數的建構函式後,那麼就沒有預設無參的那個了,就需要自己手動寫一個 代碼如下複製代碼 /// <summary>/// 國籍的介面/// </summary>public interface INationality{
Time of Update: 2017-01-13
1、用第三個變數值交換int a = 1;int b = 2;int c = a;a = b;b = c;2、用加減法交換a = a + b;b = a - b;a = a - b;或a = a - b;b = a + b;a = b - a;3、用異或(XOR)法交換 a = a ^ b; b = a ^ b; a = a ^ b;詳細可看codeproject上一篇文章 <<神奇的異或 The Magical Exclusive OR