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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章