Test1

โปรแกรม1


using System;


namespace Hello
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine("Hello, World");
            Console.WriteLine("computer programing");
            Console.WriteLine("Praweenawat Howgratok");
            Console.ReadLine();
        }
    }
}



โปรแกรม2

using System;
namespace DemoEscapeSequences {
    class Program {
        static void Main() {
            Console.WriteLine("This line \tcontains two \ttabs");
            Console.WriteLine("This statement\ncontains a new line");
            Console.WriteLine("This statement sound three alerts\a\a\a");
            Console.ReadLine();
        }
    }
}


โปรแกรมที่4.1

using System;
namespace integerRange{
    class Program{
        static void Main() {
            Console.WriteLine("min sbyte = " + SByte.MinValue);
            Console.WriteLine("max sbyte = " + SByte.MaxValue);
            Console.WriteLine("min byte = " + Byte.MinValue);
            Console.WriteLine("max byte = " + SByte.MaxValue);
            Console.WriteLine("min short = " + Int16.MinValue);
            Console.WriteLine("max short = " + Int16.MaxValue);
            Console.WriteLine("min ushort = " + UInt16.MinValue);
            Console.WriteLine("max Ushort = " + UInt16.MaxValue);
            Console.WriteLine("min int = " + Int32.MinValue);
            Console.WriteLine("max int = " + Int32.MaxValue);
            Console.WriteLine("min uint = " + UInt32.MinValue);
            Console.WriteLine("max uint = " + UInt32.MaxValue);
            Console.WriteLine("min long = " + Int64.MinValue);
            Console.WriteLine("max long = " + Int64.MaxValue);
            Console.WriteLine("min ulong = " + UInt64.MinValue);
            Console.WriteLine("max ulong = " + UInt64.MaxValue);
            Console.ReadLine();
        }
    }
}




โปรแกรมที่4.2

using System;
namespace DisplaySomeMoney {
    class Program {
        static void Main() {
            double someMoney = 39.45;
            double someMoney1 = 39.46;
            double someMoney2 = 39.47;
            double someMoney3 = 39.48;
            double someMoney4 = 39.49;
            double someMoney5 = 39.50;
            Console.Write("The money is ");
            Console.WriteLine(someMoney);
            Console.Write("The money is ");
            Console.WriteLine(someMoney1);
            Console.Write("The money is ");
            Console.WriteLine(someMoney2);
            Console.Write("The money is ");
            Console.WriteLine(someMoney3);
            Console.Write("The money is ");
            Console.WriteLine(someMoney4);
            Console.Write("The money is ");
            Console.WriteLine(someMoney5);
            Console.ReadLine();
        }
    }
}




โปรแกรมที่4.4

using System;
namespace Relational
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = 17;
            int y = 5;
            Console.WriteLine("{0} == {1} = {2}", x, y, x == y);
            Console.WriteLine("{0} != {1} = {2}", x, y, x != y);
            Console.WriteLine("{0} < {1} = {2}", x, y, x < y);
            Console.WriteLine("{0} <= {1} = {2}", x, y, x <= y);
            Console.WriteLine("{0} > {1} = {2}", x, y, x > y);
            Console.WriteLine("{0} >= {1} = {2}", x, y, x >= y);
            Console.ReadLine();
        }
    }
}

โปรแกรมที่ 4.5
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = 4;
            int y = 5;
            Console.WriteLine("x = {0}, y = {1}", x, y);
            bool result = true || (++x == y);
            Console.WriteLine("result = {0}", result);
            Console.WriteLine("x = {0}, y = {1}", x, y);

            result = true && (++x == y);
            Console.WriteLine("result = {0}", result);
            Console.WriteLine("x = {0}, y = {1}", x, y);
            Console.ReadLine();
        }
    }
}