标签:
static void Main()
{
string c=Console.ReadLine();
string d=Console.ReadLine();
Console.WriteLine(c+","+d); //用“+”连接符
}
static void Main()
{
string c=Console.ReadLine();
string d=Console.ReadLine();
string m=String.Format(“{0},{1}”,c,d); //字符串格式输出
Response.Write(m);
}
protected void Page_Load(object sender, EventArgs e)
{
int i=12345;
Response.Write("{0:C}",i); //货币
Response.Write("{0:D}",i); //十进制数
Response.Write("{0:E}",i); //科学技术法
Response.Write("{0:F}",i); // 浮点数表示法
Response.Write("{0:G}",i); //G或g General 常用格式
Response.Write("{0:N}",i); //N或n 用逗号分割千位的数字
}
protected void Page_Load(object sender, EventArgs e)
{
string s1 = "三百";
string s2 = "1000";
string s3 = "2,000";
string s4 = "-1000";
string s5 = "4000d";
int currentValue = 0;
Response.Write(int.TryParse(s1, out currentValue)); //返回False
Response.Write(int.TryParse(s2, out currentValue)); //返回True
Response.Write(int.TryParse(s3, out currentValue)); //返回False
Response.Write(int.TryParse(s4, out currentValue)); //返回True
Response.Write(int.TryParse(s5, out currentValue)); //返回False
}
protected void Page_Load(object sender, EventArgs e)
{
string str = "Do you like ASP.NET?";
Response.Write(str.ToUpper()); //转换为大写
Response.Write(str.ToLower()); //转换为小写
}
d MM/dd/yyyy ShortDatePattern(短日期模式)
D dddd,MMMM dd,yyyy LongDatePattern(长日期模式)
F dddd,MMMM dd,yyyy HH:mm Full date and time (long date and short time)(全日期和时间模式)
F dddd,MMMM dd,yyyy HH:mm:ss FullDateTimePattern (long date and long time)(长日期和长时间)
G MM/dd/yyyy HH:mm General (short date and short time)(通用模式,短日期和短时间)
G MM/dd/yyyy HH:mm:ss General (short date and long time)(通用模式,短日期和长时间)
M,M MMMM dd MonthDayPattern(月天模式)
r,R ddd,dd MMM yyyy,HH‘:‘mm‘:‘ss ‘GMT‘ RFC1123Pattern (RFC1123模式)
S yyyy-MM-dd HH:mm:ss SortableDateTimePattern (conforms to ISO 8601) using local time(使用本地时间的可排序模式)
T HH:mm ShortTimePattern (短时间模式)
T HH:mm:ss LongTimePattern(长时间模式)
U yyyy-MM-dd HH:mm:ss UniversalSortable-DateTimePattern (conforms to ISO 8601) using universal time(通用可排序模式)
U dddd,MMMM dd,yyyy,HH:mm:ss UniversalSortable-DateTimePattern(通用可排序模式)
y,Y MMMM,yyyy YearMonthPattern(年月模式)
static void Main()
{
Response.Write("{0:D}",DateTime.Now); //输出到天
Response.Write("{0:y}",DateTime.Now); //输出到月
Response.Write("{0:m}",DateTime.Now); //取出是那个月
Response.Write("{0:T}",DateTime.Now); // 取长时间到秒
Response.Write("{0:t}",DateTime.Now); //取短时间到分
Response.Write("{0:tt}",DateTime.Now); //取出是上午还是下午
}
标签:
原文地址:http://www.cnblogs.com/liuyudong0825/p/4935749.html