zoukankan      html  css  js  c++  java
  • Simple statements, blocks, Write, WriteLine and the format string.

            static void  SimpleProgram()
            // A block is a sequence of zero or more statements enclosed by a matching set of curly braces; it acts as a single syntactic statement.
            {
                //A statement is a source code instruction describing a type or telling the program to perform an action.
                int var1 = 5;
    
                //Write is a menber of the Console class. It sends a text string to the program's console window.
                System.Console.Write("This is trival text.");
    
                //WriteLine is another member of Console, which performs the same functions as Write but appends a newline character to the end of each output string.
                System.Console.WriteLine("The value of var1 is {0}", var1); 
    
                //The first parameter must always be a string and is called the format string.
                //The format string can contain substitution markers
                //A substitution marker marks the position in the format string where a value should be substituted in the output string.
                //It consists of an integer enclosed in a set of matching curly braces. The integer is the numeric position of the substitution value to be used.
                //The parameters following the format string are called substitution values. These substitution values are numbered, starting at 0.
                System.Console.WriteLine("Two sample integers are {1}, {0} and {1}.", 3, 6);
    
                //A marker must not attempt to referrence a value at a position beyond the length of the list of substition values. 
                //If it does, it will not produce a compile error but a runtime error (called an exception).
            }
  • 相关阅读:
    How to solve problems
    【Python】区分List 和String
    【Python】内置方法pop
    【Python】安装配置Anaconda
    【Web crawler】print_all_links
    【Python】多重赋值之值互换
    BNF巴科斯-诺尔范式
    Svn与Git的区别
    python项目部署
    linux每日命令(3):which命令
  • 原文地址:https://www.cnblogs.com/limeina/p/3520789.html
Copyright © 2011-2022 走看看