C# 结构体初始化
摘要:public struct MyStruct { public string s; public int length; public static implicit operator MyStruct(string value) { return new MyStruct() { s = value, length = value.Length }; }}Example:MyStruct myStruct = "Lol";Console.WriteLine(myStruct.s);Console.WriteLine(myStruct.length);Output:Lol3
阅读全文
posted @
2013-04-30 18:58
武胜-阿伟
阅读(3413)
推荐(0) 编辑
转换编码方式
摘要:public string UtfEncode(string str) { byte[] buffer = Encoding.GetEncoding("UTF-8").GetBytes(str); string result = ""; for (int i = 0; i < buffer.Length; i++) { result = result + "%" + buffer[i].ToString("x"); } return result; }
阅读全文
posted @
2013-04-28 11:33
武胜-阿伟
阅读(169)
推荐(0) 编辑
跨线程更新控件UI
摘要:private void btnCalculate_Click(object sender, EventArgs e) { Thread mythread = new Thread(Calculate); mythread.IsBackground = true; //設置為後臺線程,程式關閉后進程也關閉,如果不設置true,則程式關閉,此線程還在內存,不會關閉 mythread.Start(); } private void Calculate() { ...
阅读全文
posted @
2013-04-28 08:41
武胜-阿伟
阅读(594)
推荐(1) 编辑
示例偌代码日期
摘要:日期格式化DateTime.Now.ToString("yyyy-M-d dddd", new CultureInfo("zh-CN"));打开网页::::: :View Code 1 private void OpenWeb() 2 { 3 string fileName = "http://www.xxx.com"; 4 try 5 { 6 Process.Start(fileName); 7 } 8 catch 9 {10 try11 ...
阅读全文
posted @
2013-04-27 11:20
武胜-阿伟
阅读(212)
推荐(0) 编辑
多線程委派 转
摘要:一般我們在實作多線程存取主線程控制項屬性時,必須以委派方式來存取,否則就有可能會出現InvalidOperationException例外, 一般初學者總會犯這個錯誤,大都不知道需要委派的動作,總是在子線程用一行textBox1.Text="aaaaa"就想改變控制項的屬性,卻 換來InvalidOperationException的錯誤,而在一般情況下委派的動作總不會 像textBox1.Text="aaaaa"短短一行就這麼直覺的解決問題,總覺得委派代碼實在麻煩。如果你運作的環境 是.netframework3.5(含以上),又覺得委派的代碼總是惹人
阅读全文
posted @
2013-04-26 10:19
武胜-阿伟
阅读(211)
推荐(0) 编辑
成交量反转交易策略(转)
摘要:成交量反转交易策略(转)李 超:感谢广大投资者长期以来对我们的支持,今天为大家讲述一种有效的短线交易策略:成交量反转策略。 市场总不缺乏赚钱的机会,只要我们潜心去研究,股市总有一些规律可以掌握,只要我们掌握了某个规律,我们就可以根据这个规律去制定我们的交易策略,按照制定的策略去操作,就会为我们带来盈利。美 国普渡大学Michael Cooper对1962到1993年的股票收益研究发现,股票一周的收益伴随着成交量的下跌趋向于在下一周反转,成交量反转策略就是基于这个规律制定出来 的,策略认为如果股票在过去的5天内下跌幅度超过股票过去100天的波动标准差,并且成交量下降1/4以上,接下来的5天股票会
阅读全文
posted @
2013-04-26 09:13
武胜-阿伟
阅读(755)
推荐(0) 编辑
一位成功人士总结的操盘程序(转)
摘要:一位成功人士总结的操盘程序(转)第一,看大盘。(确定思路和仓位)第二,选板块。(热点,翻倍)第三,定个股。(主力,龙头)第四,真操作。(决定,输赢)操作(买进+控制+卖出)①什么时候买进(选时=综合分析)②买进多少?(资金管理=先1/3)③对了=加仓(增强盈利)④错了=止损(控制风险)⑤控制=(赚钱到目标位后就止盈,减仓,清仓)注意事项:1. 绝不频繁操作(周一,二)2. 绝不随意买卖操作(按计划操作)3. 绝不分散多票操作(集中一支)4. 绝不满仓操作。(1/3、1/4、先进)5. 时间上(上午前一个小时买5日附近,下午后一个小时买突破前期高点)6. 空间上(沿5日附近,不高于2—5%)7.
阅读全文
posted @
2013-04-26 09:12
武胜-阿伟
阅读(504)
推荐(0) 编辑
DataTableToList 优化后
摘要:View Code http://www.codeproject.com/Articles/19513/Dynamic-But-Fast-The-Tale-of-Three-Monkeys-A-Wolfusing System;using System.Collections.Generic;using System.Data;using System.Reflection;using System.Reflection.Emit;using System.Text;using System.Threading.Tasks;namespace SharpShell{ //DataTabl...
阅读全文
posted @
2013-04-25 10:42
武胜-阿伟
阅读(406)
推荐(0) 编辑
MySQL - Bulk data import using .Net connector MySqlBulkLoader Class
摘要:Lets see how do we import bulk data in MySQL database? To deal with MySQL database we first need MySQL to .Net connector, which can be downloaded from here. When you install this connector, it will give you DLLs required to deal with MySQL database from .Net code.Reference MySql.Data.dll in your .Ne
阅读全文
posted @
2013-04-24 08:35
武胜-阿伟
阅读(721)
推荐(0) 编辑
事件 示例
摘要:public static void Raise<T>(this EventHandler<T> handler, object sender, T args) where T : EventArgs{ if (handler != null) { handler(sender, args); }}public static void Raise(this EventHandler handler, object sender, EventArgs args){ if (handler != null)...
阅读全文
posted @
2013-04-23 09:11
武胜-阿伟
阅读(184)
推荐(0) 编辑
好类 笔记
摘要:View Code using System;using System.Collections.Generic;using System.Text;using System.Runtime.InteropServices;namespace CalmBeltFund.Trading.CTPStock{ internal class PInvokeUtility { static Encoding encodingGB2312 = Encoding.GetEncoding(936); public static string GetUnicodeString(byte[] str...
阅读全文
posted @
2013-04-23 08:32
武胜-阿伟
阅读(134)
推荐(0) 编辑
事件参数 定义
摘要:public class CTPEventArgs : EventArgs { public CTPResponseInfo ResponseInfo { get; internal set; } public int RequestID { get; internal set; } public CTPEventArgs(CTPResponseInfo rspInfo, int requestID) { this.ResponseInfo = rspInfo; this.RequestID = requestID; } public ...
阅读全文
posted @
2013-04-22 17:46
武胜-阿伟
阅读(364)
推荐(0) 编辑
跨线程访问窗体控件
摘要:public void SetText<T>(T control, string text) where T : Control{if (control.InvokeRequired)control.Invoke(new Action<Control, String>(SetText), new Object[] { control, text });elsecontrol.Text = text;}/////////////////委托delegate void SetEnableCallback(System.Windows.Forms.Control objCtr
阅读全文
posted @
2013-04-21 08:08
武胜-阿伟
阅读(232)
推荐(0) 编辑
(WeakReference )弱引用解决OutOfMemoryException异常
摘要:使用WeakReference 来释放那些长时间在内存中无用的大对象测试代码:View Code using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Text;using System.Runtime.Serialization.Formatters.Binary;namespace WeakReferenceTestSample{ public class SomeBigClass : List<string> { public So...
阅读全文
posted @
2013-04-17 10:40
武胜-阿伟
阅读(388)
推荐(0) 编辑
对象在内存中占有大小
摘要:this may not be accurate but its close enough for melong size =0;object o =newobject();using (Stream s =newMemoryStream()){BinaryFormatter formatter =newBinaryFormatter(); formatter.Serialize(s, o); size = s.Length;}private long ObjectSize(object o) { long size = 0; //object o = new object(); ...
阅读全文
posted @
2013-04-17 10:36
武胜-阿伟
阅读(237)
推荐(0) 编辑
算法 线性映射
摘要:float都不超过512.0, -512.0, 如何将其存储到unsigned char[3]中就是[-512,512]到[0,2^24)之间的线性映射么? 以32位机为例D,4字节unsignedint型a=-512b=512;dis=b-a=1024=2^10; unsignedchardata[3];的最大值M=n^24-1数据,Fdouble型 压缩时D=(F-a)*M/dis;可以看到D是小于等于M的,然后拷贝进数据区 解压时F=a+D*dis/M *****M大小与结果无关
阅读全文
posted @
2013-04-11 17:13
武胜-阿伟
阅读(301)
推荐(0) 编辑