zoukankan      html  css  js  c++  java
  • 002 The Variables In Csharp

    在介绍本章之前,我们先看一下C#的编译过程,如下图所示:

    图片摘自:http://www.developingthefuture.net/compilation-process-and-jit-compiler/

    The process of compilation in a managed environment (.Net, Java)
    The process of compilation in managed environments is slightly different. Let's take .Net and Java as examples. The code we write in our favourite IDE is first checked by the IDE itself. Then, when compiled into object files and linked into dynamic/static libraries or executables, it is checked again, and finally it is checked at runtime. One common characteristic of the managed environments is that the compiler does not produce binary code, but rather intermediate meta-code, called MSIL - Microsoft Intermediate Language in .Net and Bytecode in Java.

    After that, the MSIL is translated to binary code at runtime by the JIT (Just In Time) compiler, meaning that the code you write is only interpreted when it is actually used. This allows the CLR (Common Language Runtime) to precompile and optimize your code, achieving improved performance, at the cost of increased startup time. But you can also precompile your application using Ngen (Native Image Generator) to speed up the startup, without the benefits of runtime optimization.

    C#是静态类型的语言,需要编译,所以我在使用变量前必须告诉编译器变量的类型。我们使用如下所示的语法定义变量:

    int a = 1; //定义一个整数类型的变量a
    float b = 1f;//定义一个float类型的变量b
    char c= 'a';//定义一个字符类型的变量c
    string str= "gavinsun";//定义一个字符串类型的变量str
    bool isTrue= true;//定义一个bool类型的变量isTrue
  • 相关阅读:
    MySQL导出数据到文件中
    MySQL表内更新时,自动记录时间
    MySQL实现分页查询
    shell 中执行Oracle查询和执行存储过程
    python调用其他脚本
    hadoop 中ALL Applications 中Tracking 下History查找不到MapReduce Job 日志
    Matplotlib 随机漫步图
    Matplotlib 绘图
    shell中$(( ))、$( )、``与${ }的区别详解
    jquery动画切换引擎插件 Velocity.js 学习01
  • 原文地址:https://www.cnblogs.com/tantanjishu/p/4923089.html
Copyright © 2011-2022 走看看