|
|
|
|
|
|
C++的第二个简单的类
摘要:1 // Cplus001.cpp : Defines the entry point for the console application. 2 // 3 4 #include "stdafx.h" 5 #include "iostream" 6 #include "string" 7 8 using namespace std; 9 10 //the definition of class11 class Person12 {13 public:14 void speak();15 private:16 string words
阅读全文
三种画图不会消失的办法
摘要:1 protected override void OnPaint(PaintEventArgs e) 2 { 3 Graphics g = e.Graphics; 4 } 5 private void Pbo_Paint(object sender,PaintEventArgs e) 6 { 7 Graphics g = e.Graphics; 8 } 9 private void Frm_Paint(object sender,PaintEventArgs e)10 {11 Graphics g = e.Graphics;12 }其中Pbo_Paint和Frm_P...
阅读全文
数组复制与拷贝的问题
摘要:1 string t = "I love you.";2 string tt = t;3 tt = "I do love you.";4 Console.WriteLine(t);结果是:I love you.string[] template = { "I love you", " China." };string[] tmp = template;tmp[0] = "I do love you";Console.WriteLine(template[0]);结果是:I do love you
阅读全文
PHP和CS的引用传值
摘要:PHP的引用传值function change_value($num){ $num+=2;}$age = 3;change_value(&$age);echo $age;CS的引用传值static void Main(string[] args){ int age = 3; Console.WriteLine(change_value(ref age));}static int change_value(ref int num){ num += 2; return num;}
阅读全文
CS对于dll文件的引用
摘要:1.对于.net或者com型的组件,直接添加引用即可。2.对于标准的dll文件,利用DLLImport这个函数即可,如果要使用函数的别名,那么应该加入EntryPoint。示例:一般可以封装成一个类,然后在其他类中引用即可。using System.Runtime.InteropServices;public class MyWin32Wrapper{ [DllImport("User32.dll")] static public extern void Beep(int frequency,int duration);}
阅读全文
CS异步下载
摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.IO;using System.Net;using System.Text;using System.Windows.Forms;namespace 下载示例{ public delegate void form1ContentControl(bool isFinish); public partial class Form2 : F...
阅读全文
文件编码大全
摘要:class Program{ static void Main(string[] args) { for (int i = 0; i < 65535; i++) { try { Console.WriteLine("{0} {1}}", i.ToString(),Encoding.GetEncoding(i).WebName); } catch { } } }}
阅读全文
字符串、流、字节、字符之间的转换
摘要:(1)流转换成字节 fs.seek(0,SeekOrigin.Begin); byte[] fsbyte = new byte[fs.length]; fs.Read(fsbyte,0,fsbyte)(2)字节转换成流 Stream stream = new MemoryStream(bytes);【字符串和字节的转换】 bt_content = Encoding.Default.GetBytes(str_content); //此处不可吧Default转换成UTF8,否则造成转了两次,就乱码了。 str_content = Encoding.UTF8.GetString(bt_content
阅读全文
c#获取网页内容的三种方法
摘要:1.webclientWebClient wc = new WebClient();Stream stm = wc.OpenRead(str_url);StreamReader sr = new StreamReader(stm,Encoding.UTF8);//Encoding这个类的属性有:UTF8,Unicode等等Console.Write(sr.ReadToEnd());2.HttpWebRequest hwrq = (HttpWebRequest)WebRequest.Create(str_url);HttpWebResponse hwrp = (HttpWebResponse)h
阅读全文
C#读写xml文件
摘要:using System.Xml.Linq;protected void WriteXml(string path){ XDocument Xdoc = new XDocument( new XDeclaration("1.0","utf-8","yes"), new XComment("Create Time:"+DateTime.Now), new XElement("mybook", new XElement("bookfir", new XAttribute(&quo
阅读全文
C#右键复制路径
摘要:using System;//Environmentusing System.Windows.Forms;//add referece of System.Windows.Forms :DataFormatsnamespace getfilepath{ class Program { [STAThreadAttribute] //由于操作剪贴板是多线程,故必须加上上边那个标识符,STAThread]是 //Single Thread Apartment单线程套间的意思,是一种线程模型 public stat...
阅读全文
C++类(一)
摘要:1 #include 2 #include 3 4 using namespace std; 5 6 7 //找了很久,似乎都是类放在Main方法体上 8 9 class Person10 {11 private:12 string str_name;13 public:14 Person(string str)15 {16 str_name = str;17 }18 string Speak()19 {20 return s...
阅读全文
纪念大一的日子,一个简单的C++
摘要://Author:xtyang//记得大一学C语言,永远都不明白如何调用一个函数,真是好可爱呀。#includeusing namespace std;//定义函数原型int add(int m,int n);int minus(int m,int n);//Main,程序入口int main(){ int r,p,res,opt; cout>opt; cout>r>>p; switch(opt) { case 1: res = add(r,p); break; case 2: res = minus(r,p); break; default: res = 0; ...
阅读全文
CS加密算法
摘要:概述:加密数据可以使用对称加密或非对称加密算法,使用对称加密比非对称密钥快得多,但对称密钥需要解决安全交换密钥的问题。在.NET Framework中,可以使用System.Security.Cryptography命名空间中的类来加密。它实现了几个对称和非对称算法。从.NET 3.4开始,一些新类以Cng作为前缀或后缀,表示Cryptography Next Generation,用于采用Windows NT 6.0或更高内核版本的操作系统(Vista,Win7,Win8)API可以使用基于提供程序的模型,编写独立于算法的程序。System.Security.Cryptography命名空间
阅读全文
串联不同数组的小技巧
摘要:有时我们需要将某一种类型的数组的所有元素以字符串的形式串联起来,一般的方法我们通过for循环就可以办到,当然如果是字符串数组,直接用string.Concat即可,但是对于其他类型的数组,确实没有这个函数的。那么有没有别的办法呢?本例旨在介绍一种这样串联任何数组的方法。 1: string str_key = "danxin"; 2: string str_hash = "welcome to you."; 3: HMACSHA1 hmsha = new HMACSHA1(Encoding.Default.GetBytes(str_key)); 4: b
阅读全文
利用Form()使绘图可以不消失
摘要:1: public Form1() 2: { 3: InitializeComponent(); 4: this.Show(); 5: Graphics grp = this.CreateGraphics(); 6: Pen p = new Pen(Color.Black, 2); 7: grp.DrawLine(p, new Point(0, 0), new Point(100, 100)); ...
阅读全文
如何画折线和曲线
摘要:画折线 1: private void DrawLines(Graphics grp, List pointList) 2: { 3: Point one, two; 4: for (int i = 0; i pointList) 2: { 3: Point[] temps = new Point[pointList.Count]; 4: pointList.CopyTo(temps); 5: ...
阅读全文
用Drawing画图如何不会消失
摘要:方法一:将事件放在form_Load中,在窗体中画图 1: protected void MainForm_Load(object sender,EventArgs e) 2: { 3: InitialPoint(); 4: Bitmap bm = new Bitmap(this.Width,this.Height); 5: Graphics grp = Graphics.FromImage(bm); 6: Draw...
阅读全文
图标提取以及图标转换
摘要:程序附件using System;using System.Collections.Generic;using System.Drawing;using System.Windows.Forms;using System.IO;using System.Resources;using System.Reflection;using System.Runtime.InteropServices;namespace newExtIcon{ public partial class MainForm : Form { public Assembly asm = As...
阅读全文
|
|