Time of Update: 2018-12-08
複製代碼 代碼如下:#include <stdio.h>#include <stdlib.h>typedef struct Node { int data; struct Node *next;} Node;void getInfo(Node * node);int printNodes(Node *node);void saveToFile(Node * node, char * filename);void readFromFile(char *
Time of Update: 2018-12-08
複製代碼 代碼如下:#include <stdio.h>int binSearch(int arr[], int low, int high, int key);int binSearch2(int arr[], int low, int high, int key);int binSearch3(int arr[],int start,int ends,int key);int main() { int arr[]={3,8,11,15,17,22,23,26,28,29,3
Time of Update: 2018-12-08
效果描述:有三個表單然後順序分別是(1)點擊第一個表單中的按鈕彈出第二個表單,隱藏第一個表單(2)第二個表單到一定時間彈出第三個表單(3)點擊第三個表單的按鈕關閉第三個和第二個表單,彈出第一個表單From1複製代碼 代碼如下:using System; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form {
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
效果描述:有兩個表單,FORM1(一個名為“開啟form2”的button控制項)和FORM2(一個名為“改變form1顏色“的button控制項)。啟動時,FORM1中點擊button控制項“開啟form2””使FORM2顯示出來。點擊FORM2中的“改變form1顏色”後,Form1中顏色改變。一、在Form2裡面: 首先聲明一個委託和委託執行個體Form2類外複製代碼 代碼如下:public delegate void ChangeFormColor(bool topmost)
Time of Update: 2018-12-08
複製代碼 代碼如下:[DllImport("kernel32.dll", EntryPoint = "GetSystemDefaultLCID")] public static extern int GetSystemDefaultLCID(); [DllImport("kernel32.dll", EntryPoint = "SetLocaleInfoA")] public static extern int SetLocaleInfo(int
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
複製代碼 代碼如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.Xml;using
Time of Update: 2018-12-08
一、普通Singleton複製代碼 代碼如下:#include<iostream>using namespace std;class Singleton{ public: static Singleton* getInstance(); private: static Singleton* instance; Singleton() { cout<<"constructor\n";
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
1、使用FileStream讀寫檔案 檔案頭:複製代碼 代碼如下:using System;using System.Collections.Generic;using System.Text;using System.IO;讀檔案核心代碼:複製代碼 代碼如下:byte[] byData = new byte[100];char[] charData = new char[1000];try{FileStream sFile = new
Time of Update: 2018-12-08
App.config中寫(注意C#中的應用程式設定檔名不能修改)複製代碼 代碼如下:<?xml version="1.0" encoding="utf-8" ?><configuration> <connectionStrings> <add name="URL" connectionString="http://www.hao123.com"/> <add name="IP" connectionString="192.168
Time of Update: 2018-12-08
方法如下:在表單的Load事件註冊滾動事件,並增加對應的方法 複製代碼 代碼如下:private void FormSample_Load(object sender, EventArgs e) { //註冊事件 this.MouseWheel += new MouseEventHandler(FormSample_MouseWheel); } /// <summary> ///
Time of Update: 2018-12-08
反射提供了封裝程式集、模組和類型的對象(Type 類型)。可以使用反射動態建立類型的執行個體,將類型綁定到現有對象,或從現有對象擷取類型並調用其方法或訪問其欄位和屬性。如果代碼中使用了屬性,可以利用反射對它們進行訪問。下面我就以一個案例來說明反射在項目中的使用方法。大體分為三個步驟:第一步,在web.config配置如下代碼(目的是為了動態去修改所需分析的dll)複製代碼 代碼如下:<appSettings> <add key="BizAssembly" value=
Time of Update: 2018-12-08
複製代碼 代碼如下: //路徑, 添加開機啟動/刪除開機啟動 public static void SetAutoRun(string fileName, bool isAutoRun) { RegistryKey reg = null; try { if (!System.IO.File.Exists(fileName))
Time of Update: 2018-12-08
複製代碼 代碼如下:/// <summary> /// 刪除掉空檔案夾 /// 所有沒有子“檔案系統”的都將被刪除 /// </summary> /// <param name="storagepath"></param> public static void KillEmptyDirectory(String storagepath) {
Time of Update: 2018-12-08
複製代碼 代碼如下:// hello.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "stdio.h"int _tmain(int argc, _TCHAR* argv[]){ FILE *file1,*file2; file1=fopen("047facesmall.obj","r"); //讀檔案