C#入门经典:第三章 变量和表达式 | 少将全栈
  • 欢迎访问少将全栈,学会感恩,乐于付出,珍惜缘份,成就彼此、推荐使用最新版火狐浏览器和Chrome浏览器访问本网站。
  • 吐槽,投稿,删稿,交个朋友
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏少将全栈吧

C#入门经典:第三章 变量和表达式

点滴 admin 11年前 (2013-09-24) 1847次浏览 已收录 扫描二维码

<

p>
1.C#编译器不考虑代码中间的空格、回车符或tab字符(这些字符统称为空白字符)。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Chapter03
{
    class Program
    {
        static void Main(string[] args)
        {
            int myInterger;
            string myString;
            myInterger = 17;
            myString = ""myInteger" is";
            Console.WriteLine("{0} {1}.", myString, myInterger);
            Console.ReadKey();
        }
    }
}
<p>
    <br />
</p>
<p>
    <br />
</p>
<p>
    <br />
</p>
<p>
    <a id="ematt:543" href="http://www.whatled.com/content/uploadfile/201309/10fb1380031228.png" target="_blank"><img title="点击查看原图" border="0" alt="3.png" src="http://www.whatled.com/content/uploadfile/201309/10fb1380031228.png" width="669" height="84" /></a> 
</p>
<p>
    <br />
</p>
<p>
    <br />
</p>
<p>
    <br />
</p>
<p>
    <br />
</p>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Chapter03
{
    class Program
    {
        static void Main(string[] args)
        {
            double firstNumber, secondNumber;
            string userName;
            Console.WriteLine("Enter your name:");
            userName = Console.ReadLine();
            Console.WriteLine("Welcome {0}!", userName);
            Console.WriteLine("Now give me a number:");
            firstNumber = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("Now give me another number:");
            secondNumber = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("The sum of {0} and {1} is {2}.", firstNumber, secondNumber, firstNumber+secondNumber);
            Console.WriteLine("The result of subtracting {0} and {1} is {2}.", firstNumber, secondNumber, firstNumber - secondNumber);
            Console.WriteLine("The product of {0} and {1} is {2}.", firstNumber, secondNumber, firstNumber * secondNumber);
            Console.WriteLine("The result of dividing {0} by {1} is {2}",firstNumber, secondNumber, firstNumber / secondNumber);
            Console.WriteLine("The remainder after dividing {0} by {1} is {2}", firstNumber , secondNumber , firstNumber % secondNumber);
            Console.ReadKey();
        }
    }
}
<p>
    <br />
</p>
<p>
    <br />

4.png

<p>
    <br />
</p></p>
喜欢 (0)
[🍬谢谢你请我吃糖果🍬🍬~]
分享 (0)
关于作者:
少将,关注Web全栈开发、项目管理,持续不断的学习、努力成为一个更棒的开发,做最好的自己,让世界因你不同。