对之前.net项目的零碎知识点总结(自我学习用)

来源:互联网 发布:手机淘宝怎么找试衣间 编辑:程序博客网 时间:2024/06/04 15:26
//日文系统中对假名和数字混合情况下的长度判断if (2 * this.tNedit_PayeeCode_Ed.Text.ToString().Length == Encoding.Default.GetByteCount(this.tNedit_PayeeCode_Ed.Text.ToString())){this.tNedit_PayeeCode_Ed.Clear();}if (2 * this.tNedit_PayeeCode_St.Text.ToString().Length == Encoding.Default.GetByteCount(this.tNedit_PayeeCode_St.Text.ToString())){this.tNedit_PayeeCode_St.Clear();}//对string输出formaterrMessage = string.Format("错误信息{0}", ct_NoInput);//类型转换parameter as ClassName;//对于日期控件没有输入的判断argetDateEdit.GetDateTime() == DateTime.MinValue//用的比较多的泛型集合Dictionary<string, string> tempValue = new Dictionary<string, string>();//遍历Dictionaryforeach (KeyValuePair<string, string> entrytemp in sectCodeDic){string.IsNullOrEmpty(entrytemp.Value)}//List<>List<ClassName> _detailList = new List<ClassName>();//hashtableHashtable main = new Hashtable();main.Add(key,value);Hashtable detail = new Hashtable();detail.Add(key,value);appearanceTable = new Hashtable[2];appearanceTable[0] = main;appearanceTable[1] = detail;//gridthis.gridName.Rows[rowIndex].Cells[COLUMN_SECTIONCODE].Value = string.Empty;//输出固定长度//.ToString("000000");//转换为int类型int.Parse(string)//几种安全类型转换//object→stringprivate string StrObjectToString(object targetValue){    if ((targetValue == DBNull.Value) || (targetValue == null) || ((string)targetValue == string.Empty))    {        return string.Empty;    }    return (string)targetValue ;}//object→intprivate int StrObjectToInt(object targetValue){    if ((targetValue == DBNull.Value) || (targetValue == null) || ((string)targetValue == string.Empty) || (int.Parse((string)targetValue) == 0))    {        return 0;    }    return int.Parse((string)targetValue);}private string CellTextToString(string cellText){    if ((cellText == null) || (cellText.Trim() == string.Empty))    {        return string.Empty;    }    return cellText.Trim().PadLeft(2, '0');}private int CellTextToInt(string cellText){    if ((cellText == null) || (cellText.Trim() == string.Empty))    {        return 0;    }    return int.Parse(cellText.Trim());}//关于Timer控件的使用//在其他地方设置为true时,立即触发private void Initial_Timer_Tick(object sender, EventArgs e){    this.Initial_Timer.Enabled = false;    //触发函数    ScreenReconstruction();}//关于Encoding的使用Encoding encoding = System.Text.Encoding.GetEncoding("Shift_JIS");encoding.GetByteCount(e.KeyChar.ToString());

0 0
原创粉丝点击