C#编程--ref,out,TryParse

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void add(ref int i)
        {
            i++;
        }
        static void add2(out int i)
        {
            //这里认为i没有被初始化
            i = 111;
        }
        static void Main(string[] args)
        {
            int i = 10;
            //add(ref i);

            add2(out i);
            Console.WriteLine(i);

            bool temp = int.TryParse("aa", out i);
            Console.WriteLine(temp);


            Console.ReadKey();
        }
    }
}
 

本文出自 “Kenan_ITBlog” 博客,请务必保留此出处http://soukenan.blog.51cto.com/5130995/1076245

发布了115 篇原创文章 · 获赞 0 · 访问量 3万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章