Time of Update: 2018-12-08
複製代碼 代碼如下:using System;using System.Data;using System.Configuration;using System.Text;using System.CodeDom.Compiler;using Microsoft.CSharp;using System.Reflection;namespace EvalGuy{ /// <summary> /// 本類用來將字串轉為可執行文本並執行 /// 從別處複製,勿隨意更改!
Time of Update: 2018-12-08
複製代碼 代碼如下:#include<stdio.h>#include<string.h>#include <malloc.h>void q_sortB(char str[20][20], int n);void qs(char str[20][20],int n);void main() { int i, n; char str[20][20] = { { "Adam" }, { "Bob" }, { "Dimen" }, { "Colin" }
Time of Update: 2018-12-08
1.類中成員的存取修飾詞方位修飾符就是確定該成員能夠訪問(使用)的地區。C#中常用的有如下修飾符:pubic(公有)、private(私人)、internal(內聯)、protected(受保護)。舉例說明各個修飾符的限制地區。 複製代碼 代碼如下:class TestClass { public int a = 0; private int b = 0; protected int c = 0;pulic static int d=0;
Time of Update: 2018-12-08
繼承 在現有類(稱為基類、父類)上建立新類(稱為衍生類別、子類)的處理過程為繼承。衍生類別能自動擷取基類(除了建構函式和解構函式外的所有成員),可以在衍生類別中添加新的屬性和方法擴充其功能。複製代碼 代碼如下:using System;using System.Collections.Generic;using System.Linq;using System.Web;public class Person{ private string _id; public string
Time of Update: 2018-12-08
複製代碼 代碼如下: /// <summary> /// 合并GridView中某列相同資訊的行(儲存格) /// </summary> /// <param name="GridView1"></param> /// <param name="cellNum"></param> public static void GroupCol(GridView GridView1, int
Time of Update: 2018-12-08
近段時間,有朋友叫Insus瞭解一下反射(Reflection)方面的知識,反射提供了封裝程式集、模組和類型的對象(Type類型)。可以使用反射動態建立類型的執行個體,將類型綁定到現有對象,或從現有對象擷取類型並調用其方法或訪問其欄位和屬性。如果代碼中使用了屬性,可以利用反射對它們進行訪問。 下面的例子,是Insus練習對一個類別的屬性進行set和get值。 首先寫一個類,再寫一個可讀寫的屬性: 複製代碼 代碼如下:using System; using
Time of Update: 2018-12-08
複製代碼 代碼如下:private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.textBox1.Text.Trim())) { MessageBox.Show("請輸入需要轉換的資訊!"); return; }
Time of Update: 2018-12-08
複製代碼 代碼如下:/// <summary> /// 刪除掉空檔案夾 /// 所有沒有子“檔案系統”的都將被刪除 /// </summary> /// <param name="storagepath"></param> public static void KillEmptyDirectory(String storagepath) {
Time of Update: 2018-12-08
通過觀察發現矩陣的下標有這樣一個規律:a行遞增後b列遞增然後c行遞減再d列遞減,但是對應值卻是逐漸增加的。因此可用4個迴圈實現,需要注意的是在賦值時不要把之前的值覆蓋了。所以在這裡選擇相同顔色部分賦值,代碼如下:複製代碼 代碼如下:#include <iostream>#include <iomanip>using namespace std;// 輸出螺旋矩陣void Matrix(){ const int size = 10; // 矩陣大小 int
Time of Update: 2018-12-08
複製代碼 代碼如下:public static IPAddress GetHostIP(){ IPHostEntry ipe = Dns.GetHostEntry(Dns.GetHostName()); IPAddress ip = ipe.AddressList[0]; return ip;}private String GetIPAddress(){ String str;
Time of Update: 2018-12-08
c:複製代碼 代碼如下:#include<stdio.h>int main(int argc,char* argv[]){ char test[]="c語言輸出重新導向測試"; int i; if (freopen("F:\\雜檔案\\test.txt", "w", stdout)==NULL) fprintf(stderr, "重新導向錯誤!無法輸出到文本\n"); for(i=0;i<=9;i++) {
Time of Update: 2018-12-08
最近在編寫C++程式的過程中,需要使用matlab產生的.mat檔案,於是尋找了基本使用方法。 我的電腦環境是win7 64位系統,VS2010,matlab R2010b。 一、工程配置: 1.VC++目錄->包含目錄 添加: MATLAB\R2010b\extern\include MATLAB\R2010b\extern\include\win64 ->庫目錄 添加: MATLAB\R2010b\extern\lib\win64\microsoft
Time of Update: 2018-12-08
源碼:複製代碼 代碼如下:[StructLayout(LayoutKind.Explicit)] public struct IP { public IP(UInt32 value) { this._text1 = 0; this._text2 = 0; this._text3 = 0; this._text4 = 0; this._value = value; } public
Time of Update: 2018-12-08
Insus.NET的解決方案,是使用Factory 方法來處理,可以建立一個工廠介面,然後每個方法設計為一個工廠類,並實現工廠介面。 工廠介面: 複製代碼 代碼如下:IGetFactory using System; using System.Collections.Generic; using System.Linq; using System.Web; /// <summary> /// Summary description for IGetFactory ///
Time of Update: 2018-12-08
1. foreach語句C#編譯器會把foreach語句轉換為IEnumerable介面的方法和屬性。複製代碼 代碼如下: foreach (Person p in persons) { Console.WriteLine(p); }foreach語句會解析為下面的程式碼片段。•調用GetEnumerator()方法,獲得數組的一個枚舉•在while迴圈中,只要MoveNext()返回true,就一直迴圈下去•用Current屬性訪問數組中的元素複製代碼 代碼如下: IEnumerator
Time of Update: 2018-12-08
•靜態建構函式既沒有存取修飾詞,也沒有參數。•如果沒有編寫靜態建構函式,而這時類中包含帶有初始值設定的靜態欄位,那麼編譯器會自動產生預設的靜態建構函式。•在建立第一個類執行個體或任何靜態成員被引用時,.NET將自動調用靜態建構函式來初始化類,也就是說我們無法直接調用靜態建構函式,也就無法控制什麼時候執行靜態建構函式了。•如果類中包含用來開始執行的 Main 方法,則該類的靜態建構函式將在調用 Main 方法之前執行。•如果類中的靜態欄位帶有初始化,則靜態欄位的初始化語句將在靜態建構函式之前運行。
Time of Update: 2018-12-08
本人根據網路多個相關部落格文章原創1)產生dll建立兩個檔案 xxx.h , xxx.cppxxx.h內容如下:#ifdef BUILD_XXX_DLL#define EXPORT __declspec(dllexport)#else#define EXPORT __declspec(dllimport)#endifextern "C"{EXPORT void example(void);... ...}xxx.cpp內容如下:#define BUILD_XXX_DLL#include
Time of Update: 2018-12-08
複製代碼 代碼如下:usingSystem; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Drawing; usingSystem.IO; namespaceMicrosoft.Form.Base { classImageToByte { /// <summary> /// 圖片轉換成位元組流 /// &
Time of Update: 2018-12-08
主表單代碼如下:複製代碼 代碼如下:public partial class PrintFileForm : Form { public PrintFileForm() { InitializeComponent(); PrintFile prinFile = new PrintFile(); prinFile.Print(); } }列印檔案類如下:複製代碼
Time of Update: 2018-12-08
有m*n(m <=100,n <=100)個金幣在案頭上排成一個m行n 列的金幣陣列。每一枚金幣或正面朝上或背面朝上。用數字表示金幣狀態,0表示金幣正面朝上,1 表示背面朝上。 金幣陣列遊戲的規則是: (1)每次可將任一行金幣翻過來放在原來的位置上; (2)每次可任選2 列,交換這2 列金幣的位置。 編程任務:給定金幣陣列的初始狀態和目標狀態,編程計算按金幣遊戲規則,將金幣陣列從初始狀態變換到目標狀態所需的最少變換次數。 Input 輸入資料有多組資料。第1行有1