zoukankan      html  css  js  c++  java
  • 烂记性不如好笔头㈠㈢㈥

    1、 

    Convert  //类型转换

     例如:Convert.ToInt32(string value)

     2、

    SubString  //截取字符串

    string   str   =   OldString.SubString(int   start,int   length);
    从start位置开始截取length长度的字符串
     3、
    string str1 = "abcde";
     char newstr = str1[2]; //2表示字符串第三位c。得到c的char码99       
     4、
     Math.Abs(int value)  绝对值
    Math.Round( double value, 2); 五舍六入 保留2位
     
     真正四舍五入
     3.4 = Math.Round( 3.45, 1, MidpointRounding.ToEven)
    3.5 = Math.Round( 3.45, 1, MidpointRounding.AwayFromZero)

    5、
    continue;  跳转到下一循环
    6、
    运行按钮的2个方法
    Button1_Click(sender, e)
     button1.PerformClick();  
    7、
                   秒表
      private static System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
                watch.Reset();
                watch.Start();
                watch.Stop();
                watch.ElapsedMilliseconds.ToString()   返回 xxx (毫秒)
    8、 高效字符串拼接
                StringBuilder sb = new StringBuilder();
                     sb.AppendLine(“aaaaa”);
    9、 判断字符串中是否包含指定字符串   string.Contains

    public static bool TestOther1()
    {
      string s1 = "test";
      string s2 = "ttt";
      if (s1.Contains(s2))
      {
      return true;
      }
      else
      {
      return false;
      }
    }
    返回false

    10、 CheckForIllegalCrossThreadCalls = false;  允许线程访问窗体控件

    11、   System.Environment.Exit(0);  关闭程序
    这个方法比Application.Exit();退出要彻底
    可以中断所有线程

    12、
     floatNum.ToString("f2");  浮点转换字符串后 保存2个小数点.

    13、
    private void TextBox1_KeyPress(object sender, KeyPressEventArgs e) 
    {
     //设置按Enter键和Esc键不发出Beep声音
     if (e.KeyChar == (char)Keys.Enter || e.KeyChar == (char)Keys.Escape)
     {
     e.Handled = true;
     }
     }

    14、

    .cmd.ExecuteScalar().ToString();  返回查询语句受影响的行数
    15、
    OnClientClick="return confirm('是否删除?')'  放点击参数里

    16、
    TRUNCATE TABLE 表名  删除表内全部内容 大量数据的时候使用
    17、
    string str=“aa:bb|cc:dd”;
      string[] arr = str.Split(new Char[] { ':', '|' }, StringSplitOptions.RemoveEmptyEntries);
    arr[0]=aa
    [1]=bb
    [2]=cc
    [3]=dd
    18、
                string newstr= System.Web.HttpUtility.UrlEncode(str, System.Text.Encoding.GetEncoding("utf-8")); 将字符串转换成 utf-8
    19、
     类型: timestamp,  默认值:CURRENT_TIMESTAMP  //Mysql 当前时间默认值
    20、
    md5加密
    string MD5str = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower();

    21、
    int.Parse(string);
     
  • 相关阅读:
    How to build Linux system from kernel to UI layer
    Writing USB driver for Android
    Xposed Framework for Android 8.x Oreo is released (in beta)
    Linux Smartphone Operating Systems You Can Install Today
    Librem 5 Leads New Wave of Open Source Mobile Linux Contenders
    GUADEC: porting GNOME to Android
    Librem 5 – A Security and Privacy Focused Phone
    GNOME and KDE Join Librem 5 Linux Smartphone Party
    Purism计划推出安全开源的Linux Librem 5智能手机
    国产系统之殇:你知道的这些系统都是国外的
  • 原文地址:https://www.cnblogs.com/liehuo123/p/5562193.html
Copyright © 2011-2022 走看看