using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
string Str1 = "download";
string Str2 = "DOWNLOAD";
string Str3 = String.Format("{0},{1}!!!",Str1,Str2);
DateTime dt = DateTime.Now;//获取系统当前日期
string Str4 = String.Format("{0:D}",dt);
string Str5 = String.Format("{0:M}", dt);
string Str6 = "";
Str6 = Str1.Substring(4,4);//截取字符串
A Str7 = new A();//实例化类A
Console.WriteLine(string.Compare(Str1,Str2) );//比较字符串,判断大小,返回0;1;-1
Console.WriteLine(string.Compare(Str1,Str1));
Console.WriteLine(string.Compare(Str2,Str1));
Console.WriteLine(Str1.CompareTo(Str2));
Console.WriteLine(string.Equals(Str1,Str2));//比较字符串,判断两个字符串是否相等,返回true 或false
Console.WriteLine(Str1.Equals(Str1));
Console.WriteLine(Str3);
Console.WriteLine(Str4);
Console.WriteLine(dt);
Console.WriteLine(Str5);
Console.WriteLine(Str6);
Str7.my();//调用类A中的方法
Console .ReadKey();
}
}
class A//声明一个类
{
public void my()//声明一个方法
{
string StrA = "use^life#download,you"; //声明字符串StrA
char[] separator= { '^','#',','}; //声明分割字符数组
String[] splitstrings=new String[100];//声明一个字符串数组
splitstrings = StrA.Split(separator);//分割字符串
for (int i = 0; i < splitstrings.Length; i++)//splitstrings.Length等于4
{
Console.WriteLine("item{0}:{1}",i,splitstrings[i]);
}
Console.ReadKey();
}
}
}