conversion

使用軟體: Visual c# 2008 Express

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

namespace ConsoleApplication1
{
class conversion
{
static void Main(string[] args)
{
int a = 10;
double b = 0;
b = a;
b = 20.5;
a = (int)b;
Console.WriteLine("a = " + a);
Console.WriteLine("b = " + b);

float c = 20;
c = 20.5f;
c = (float)20.5;
Console.WriteLine("c = " + c);

char d = (char)65;
Console.WriteLine("d = " + d);

Console.ReadLine();


}
}
}

UsingFloatPoint2

使用軟體: Visual c# 2008 Express

-------------------------------

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

namespace ConsoleApplication1
{
class UsingFloatPoint2
{
static void Main(string[] args)
{
char theChar1 = 'a';
char theChar2 = '文';
char theChar3 = '\x0059';
char theChar4 = '\u0058';
char theChar5 = '\a'; //鬧鐘(警示)\u0007
char theChar6 = '\b'; //退格鍵\u0008
char theChar7 = '\t'; //水平tab定位鍵\u0009
char theChar8 = '\r'; //換行字元\u000D
char theChar9 = '\v'; //垂直tab定位鍵\u000B
char theChar10 = '\f'; //換頁\u000C
char theChar11 = '\n'; //換行\u000A
char theChar12 = '\'';
//
Console.WriteLine(theChar1);
Console.WriteLine(theChar2);
Console.WriteLine(theChar3);
Console.WriteLine(theChar4);
Console.WriteLine(theChar5);
Console.WriteLine(theChar6);
Console.WriteLine(theChar7);
Console.WriteLine(theChar8);
Console.WriteLine(theChar9);
Console.WriteLine(theChar10);
Console.WriteLine(theChar11);
Console.WriteLine(theChar12);
//
Console.ReadLine();

}
}
}

UsingFloatPoint

使用軟體: Visual c# 2008 Express

--------------------------------

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

namespace ConsoleApplication1
{
class UsingFloatPoint
{
static void Main(string[] args)
{
double x = 123.45;
float y = 123.45f;
Console.WriteLine("x:" + x);
Console.WriteLine("y:" + y);
Console.ReadLine();
}
}
}

Usingintegral

使用軟體: Visual c# 2008 Express

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

namespace ConsoleApplication1
{
class Usingintegral
{
static void Main(string[] args)
{
int x = 256;
byte y = 255;
Console.WriteLine("x:" + x);
Console.WriteLine("y:" + y);
Console.ReadLine();
}
}
}

UsingConstant

使用軟體: Visual c# 2008 Express

常數宣告與使用

-------------------------

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

namespace ConsoleApplication1
{
class UsingConstant
{
static void Main()
{
int intMyInt = 123 ;
const int myConst = 456 ;

Console.WriteLine("變數 intMyInt = {0}" ,intMyInt);
Console.WriteLine("常數 myConst = {0}" ,myConst);

intMyInt = 321;
Console.WriteLine("變數 intMyInt = {0}" ,intMyInt);
Console.ReadLine();
}
}
}

UsingVariable

使用軟體: Visual c# 2008 Express

宣告 字串/整數/浮點數 變數,初始化並且輸出於主控台

------------------------------------

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

namespace ConsoleApplication1
{
class UsingVariable
{
static void Main()
{
char strMyString = 'a' ;
int intMyInt = 123 ;
float fMyFloat ;

Console.WriteLine(strMyString) ;
Console.WriteLine(intMyInt) ;

fMyFloat = 123.456f ;
Console.WriteLine(fMyFloat) ;
Console.ReadLine();

}
}
}

Sayhello

使用軟體: Visual c# 2008 Express

輸入姓名和日期的程式

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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("請依序輸入你的姓名和生日....");
Console.WriteLine(" ");
Console.Write("姓名:");
string readString = Console.ReadLine();
Console.WriteLine(" ");
Console.Write("生日:");
string readString2 = Console.ReadLine();
Console.WriteLine(" ");
Console.Write("Hello," + readString + "你好,你的生日是" + readString2 );
Console.ReadLine();
}
}
}
-----------------------------------------------------



.