http://msdn.microsoft.com/zh-cn/library/ms228504.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
//如何:串联多个字符串(C# 编程指南)
//class stringConnect1
//{
// static void Main()
// {
// string s1 = "he " + "is " + "a " + "chinese ";
// string s2 = "boy";
// string s3 = @"h
// e"+ "is";//在字符串前面加上@可以按原样输出,而不报错,若不加@则提示“常量中有换行符”
// Console.WriteLine(s1);
// Console.WriteLine(s1+s2);
// Console.WriteLine(s3);
// }
//}
//class stringConnect2
阅读全文...
http://msdn.microsoft.com/zh-cn/library/ms228599.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
//=============修改字符串内容(C# 编程指南)==========
/**/
//=========使用System.Text.RegularExpressions.Regex 类======
//class ReplaceSubstrings
//{
// string searchFor;
// string replaceWith;
// // Custom match method called by Regex.Replace
// string ReplaceMatchCase(Match m)
// {
// // Test whether the match is capitalized
// if (Char.IsUpper(m.Value[0]) == true)
// {
// // Capitalize the replacement string
// // using System.Text; ... 阅读全文...
http://msdn.microsoft.com/zh-cn/library/ms228362.aspx
// 字符串示例,其中string和String是相同的,根据喜好使用
/*
string s1 = null;
String s2 = s1;
String s3 = "";
string s4 = String.Empty;
Console.WriteLine(s2==s3);//输出结果为False
Console.WriteLine(s2 == s4);//输出结果为False
Console.WriteLine(s3 == s4);//输出结果为True;
//以上的s2赋值为null,s3,s4的赋值为空(其中String.Empty为""的替代方法)。
//且由以上输出结果可知null与""是不同的。
const string s5="I'm a chinese";//定义一个 ... 阅读全文...
using System;
class N1
{
//输出参数示例
/*
void sum(int a, int b,out int result)
{
result= a + b;
}
static void Main()
{
N1 n = new N1();
int a = 15, b = 30,r;
n.sum(a, b,out r);
Console.WriteLine("两种之和为:{0}",r);
}
*/
//值参数示例。值不被修改
static void plus(int p)
{
p++;
Console .WriteLine ("p++的值={0}",p);
}
static void Main()
{
int p = 15;
Console.WriteLine("传入的p值:{0}", p);
plus(p);
Console.WriteLine("返回的p值:{0}",p);
}
/*引用参数
static vo ... 阅读全文...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace New2
{
class Program
{
static void Main(string[] args)
{
/*数组示例1==================================================
int[] a = new int[5];//初始化数组a,共有5个元素,从a[0]到a[4]
for (int i = 0; i < a.Length; i++)
{
a[i] = i * i;
}
Console.WriteLine("a.Length={0}",a.Length );
for (int i = 0; i < a.Length; i++)
{
Console.WriteLine("a[{0}]={1}",i,a[i]);//{0}代表第一个参数位置,{1}代表第二个参数位置
}
... 阅读全文...