隨筆 - 78  文章 - 25  trackbacks - 0
          <2009年10月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          常用鏈接

          留言簿

          隨筆分類(75)

          隨筆檔案(78)

          相冊

          實用Links

          我的Links

          搜索

          •  

          積分與排名

          • 積分 - 114335
          • 排名 - 515

          最新評論

          閱讀排行榜

          評論排行榜

          ■匿名類:匿名類用來表示臨時使用的只讀數(shù)據(jù),所以必須在創(chuàng)建時初始化各字段的數(shù)據(jù),并且只能讀取這些字段的值,而不能設(shè)置這些字段的值
          如:var val=new{StrVal="a String",IntVal=12};
          val.StrVal
          val.IntVal
          val.ToString()

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

          namespace AnonymousClass
          {
              
          class Program
              {
                  
          static void Main(string[] args)
                  {
                      
          //定義匿名類
                      var val = new { StrVal = "HelloWorld", IntVal = 200 };
                      System.Console.WriteLine(
          "first variable is: {0};  theSecondVariable is:{1}",val.StrVal,val.IntVal);
                      System.Console.WriteLine(
          "val.ToString() is:{0}",val.ToString());
                      System.Console.ReadLine();

                  }
              }
          }

          結(jié)果:
          first variable is: HelloWorld;  theSecondVariable is:200
          val.ToString() is:{ StrVal = HelloWorld, IntVal = 200 }



          posted on 2009-10-26 20:00 期待明天 閱讀(3197) 評論(0)  編輯  收藏 所屬分類: CSharp
          主站蜘蛛池模板: 华阴市| 定安县| 科技| 黔西县| 巴南区| 楚雄市| 宁国市| 搜索| 斗六市| 炎陵县| 花垣县| 江阴市| 大庆市| 濉溪县| 当涂县| 开原市| 饶阳县| 宝坻区| 台北县| 曲麻莱县| 晋州市| 兴海县| 革吉县| 武平县| 大同县| 定安县| 沛县| 夹江县| 定襄县| 丹江口市| 临沂市| 镇宁| 平和县| 百色市| 绥滨县| 新乡市| 甘德县| 吉木萨尔县| 时尚| 太湖县| 万安县|