zoukankan      html  css  js  c++  java
  • Winform 积累

    1.TimeSpan

    • 时间 1 是 2011-1-2 1:00:01;
    • 时间 2 是 2011-1-12 1:00:00。

    用时间 2 减时间 1,得到一个 TimeSpan 实例。

    那么时间 2 比时间 1 多 9 天 23 小时 59 分 59 秒。

    那么,Days 就是 9,Hours 就是 23,Minutes 就是 59,Seconds 就是 59。

    2.逻辑运算符

    C#提供“与”和“或”逻辑运算符,他们能够产生更高效的代码。

    在“与”运算符中(&&),如果第一个操作数为假,那么无需考虑第二个操作数,其结果都为假

    在“或”运算符中(||),如果第一个操作数为真,那么无需考虑第二个操作数,其结果都为真

    在这两种情况下,无需计算第二个操作数的值,产生高效代码

    他们的常规样式“&”和“|”,常规样式总是计算每个操作数

    注意:在某些情况下,会有副作用

    //老梅

    using System

    class SideEffects
        {
            static void Main()
            {
                int i;
                bool someCondition = false;
                i = 0;
                // Here, i is still incremented even though the if statement fails.
                if (someCondition & (++i < 100))
                    Console.WriteLine("this won't be displayed");
                Console.WriteLine("if statement executed: " + i); // displays 1
                // In this case, i is not incremented because the short-circuit
                // operator skips the increment.
                if (someCondition && (++i < 100))
                    Console.WriteLine("this won't be displayed");
                Console.WriteLine("if statement executed: " + i); // still 1 !!
            }
        }

  • 相关阅读:
    C# 程序打包
    [置顶] 我的iOS作品
    struts2处理上传文件路径问题
    Lua基础 函数(二)
    JS解析XML的实现代码
    软件架构设计之Utility模块——Any
    详解Java解析XML的四种方法
    JS解析XML
    Android中级第八讲安卓子线程,以及定时任务使用讲解
    关于"未能映射路径"问题
  • 原文地址:https://www.cnblogs.com/myblog_myf/p/1920669.html
Copyright © 2011-2022 走看看