| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
參考網站:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
string str = "I'am 中文字";
int maxLength = 8; //擷取長度為7byte的字串
string result='';
int count = 0;
foreach(char a in str)
{
counter = counter+ System.Text.Encoding.GetEncodeing("Big5").GetBytes(str.ToString()).Length;
if(count <= maxLength)
{
result = result + a;
}
else
{
break;
}
}
System.Writeline(result+"...");
decimal myMoney = 300.5m;
decimal myMoney = 300;
decimal myMoney = 99.9m; double x = (double)myMoney; myMoney = (decimal)x;
decimal d = 9.1m; int y = 3; Console.WriteLine(d + y); // Result converted to decimal, 12.1