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

//日文系统中对假名和数字混合情况下的长度判断
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输出format
errMessage = string.Format("错误信息{0}", ct_NoInput);

//类型转换
parameter as ClassName;

//对于日期控件没有输入的判断
argetDateEdit.GetDateTime() == DateTime.MinValue

//用的比较多的泛型集合
Dictionary<string, string> tempValue = new Dictionary<string, string>();
//遍历Dictionary
foreach (KeyValuePair<string, string> entrytemp in sectCodeDic)
{	string.IsNullOrEmpty(entrytemp.Value)	}
//List<>
List<ClassName> _detailList = new List<ClassName>();

//hashtable
Hashtable 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;

//grid
this.gridName.Rows[rowIndex].Cells[COLUMN_SECTIONCODE].Value = string.Empty;

//输出固定长度
//.ToString("000000");
//转换为int类型int.Parse(string)

//几种安全类型转换
//object→string
private string StrObjectToString(object targetValue)
{
    if ((targetValue == DBNull.Value) || (targetValue == null) || ((string)targetValue == string.Empty))
    {
        return string.Empty;
    }

    return (string)targetValue ;
}
//object→int
private 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
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

chenjian0415

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值