17.03.12 .Net基础(三)

2017-03-13  本文已影响3人  CH小猫
out参数
static void Main(string[] args)
{
  int n;
  string s;
  bool b = Test(out n,out s);
  Console.Write(b);
  Console.Write(n);
  Console.Write(s);
  Console.ReadKey();
}

static bool Test(out int number, out string res)
{
  number=10;
  res = "张三";
  return true;
}
ref参数
static void Main(string[] args)
{
  int n1 = 10;
  int n2 = 10;
  Change(ref n1,ref n2);
  Console.Write("{0}---{1}",n1,n2);
  Console.ReadKey();
}

static bool Change(ref int n1, ref int n2)
{
  int temp = n1;
  n1 = n2;
  n2 = temp;
}
List泛型集合
 List<string> list1 = new List<string>() { "a", "b", "c" };
Dictionary键值对集合
//第一种遍历方式
foreach (string item in dict.Keys)
{
  Console.WriteLine("键--{0},值--{1}", item, dic[item]);
}
//第二种遍历方式
foreach(KeyValuePair<string, string> kv in dic)
{
  Console.WriteLine("键--{0},值--{1}", kv.Key, kv.Value);
}
常用类库之File类

常用方法

常用类库之Directory类

正则表达式

常用的3种情况

上一篇 下一篇

猜你喜欢

热点阅读