• 大小: 41KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-05
  • 语言: 其他
  • 标签: Demo  

资源简介

[北风网牛牛讲师8.21日LINQ入门到精通系列开始更新--Nhibernate系列专题讲座之NHibernate的五部曲(共4课时)].Demo.rar

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace ch01
{
    public partial class Form1 : Form
    {
        //定义一个委托
        public delegate string deleTransfer(string s);//注意方法签名

        public Form1()
        {
            InitializeComponent();
        }

        private void btnTest_Click(object sender EventArgs e)
        {
            //LinQ体验
            int[] arr = { 123123121545464856785};
            
            ////获取大于50的数
            ////没有LinQ我们怎么做?
            //ArrayList result = new ArrayList();
            //for (int i = 0; i < arr.Length; i++)
            //{
            //    if (arr[i] > 50)
            //    {
            //        result.Add(arr[i]);
            //    }
            //}
            ////打印result就OK了
            //for (int i = 0; i < result.Count; i++)
            //{
            //    Console.WriteLine(result[i]);
            //}

            //有了LinQ后我们可以这么做
            //获取大于50的数
           IEnumerable ie= arr.Select(p=>p).Where(p=>p>50);
            //输出---该部分代码可重用
           IEnumerator result= ie.GetEnumerator();
           while (result.MoveNext())
           {
               Console.WriteLine(result.Current);
           }
        }

        private void btnExtraMethod_Click(object sender EventArgs e)
        {
            //拓展方法----
            string s = “asEdSadaDsdSsa“;
            Console.WriteLine(s.ToUpper());
            Console.WriteLine(s.ToLower());
            Console.WriteLine(s.ToPascal());
            Console.WriteLine(s.ToPascal(2));
        }

        private void btnLambda_Click(object sender EventArgs e)
        {
            //Lambda   来源

            //.net frameWork 1.0 委托---函数指针
            //deleTransfer trans = new deleTransfer(ToPascal);//委托指向方法ToPascal
            //Console.WriteLine(trans(“abcdEFGH“));

            //.net frameWork 2.0 匿名方法
            //deleTransfer trans = delegate(string s) { return s.Substring(0 1).ToUpper() + s.Substring(1).ToLower(); };
            //Console.WriteLine(trans(“abcdEFGH“));

            //.net frameWork 3.5 Lambda
            //deleTransfer trans=(s)=>(s.Substring(0 1).ToUpper() + s.Substring(1).ToLower());
            deleTransfer trans = s =>s.Substring(0 1).ToUpper() + s.Substring(1).ToLower();
            Console.WriteLine(trans(“abcdEFGH“));
        }

        //将字符串的首写字母转化为大写字母的方法
        public string ToPascal(string s)
        {
            return s.Substring(0 1).ToUpper() + s.Substring(1).ToLower();
        }

        private void btnSelect_Click(object sender EventArgs e)
        {
            //LinQ To objects
            //泛型集合数据persons
            List persons = new List();
            persons.Add(“zhang san“);
            person

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      11776  2009-08-18 22:12  Demo\ch01\ch01\bin\Debug\ch01.exe

     文件      30208  2009-08-18 22:12  Demo\ch01\ch01\bin\Debug\ch01.pdb

     文件      14328  2009-08-18 22:12  Demo\ch01\ch01\bin\Debug\ch01.vshost.exe

     文件        490  2007-07-21 01:33  Demo\ch01\ch01\bin\Debug\ch01.vshost.exe.manifest

     文件       3719  2009-08-18 20:48  Demo\ch01\ch01\ch01.csproj

     文件       5560  2009-08-18 22:13  Demo\ch01\ch01\Form1.cs

     文件       4041  2009-08-18 21:45  Demo\ch01\ch01\Form1.Designer.cs

     文件       5814  2009-08-18 21:45  Demo\ch01\ch01\Form1.resx

     文件        631  2009-08-18 22:12  Demo\ch01\ch01\obj\Debug\ch01.csproj.FileListAbsolute.txt

     文件        847  2009-08-18 22:00  Demo\ch01\ch01\obj\Debug\ch01.csproj.GenerateResource.Cache

     文件      11776  2009-08-18 22:12  Demo\ch01\ch01\obj\Debug\ch01.exe

     文件        180  2009-08-18 22:00  Demo\ch01\ch01\obj\Debug\ch01.Form1.resources

     文件      30208  2009-08-18 22:12  Demo\ch01\ch01\obj\Debug\ch01.pdb

     文件        180  2009-08-18 20:52  Demo\ch01\ch01\obj\Debug\ch01.Properties.Resources.resources

     文件        485  2009-08-18 20:48  Demo\ch01\ch01\Program.cs

     文件       1340  2009-08-18 20:48  Demo\ch01\ch01\Properties\AssemblyInfo.cs

     文件       2858  2009-08-18 20:48  Demo\ch01\ch01\Properties\Resources.Designer.cs

     文件       5612  2009-08-18 20:48  Demo\ch01\ch01\Properties\Resources.resx

     文件       1089  2009-08-18 20:48  Demo\ch01\ch01\Properties\Settings.Designer.cs

     文件        249  2009-08-18 20:48  Demo\ch01\ch01\Properties\Settings.settings

     文件        902  2009-08-18 20:48  Demo\ch01\ch01.sln

    ..A..H.     14336  2009-08-18 22:15  Demo\ch01\ch01.suo

     文件        477  2009-08-18 21:45  Demo\readme.txt

     目录          0  2009-08-18 20:59  Demo\ch01\ch01\obj\Debug\Refactor

     目录          0  2009-08-18 20:48  Demo\ch01\ch01\obj\Debug\TempPE

     目录          0  2009-08-18 20:52  Demo\ch01\ch01\bin\Debug

     目录          0  2009-08-18 22:12  Demo\ch01\ch01\obj\Debug

     目录          0  2009-08-18 20:48  Demo\ch01\ch01\bin

     目录          0  2009-08-18 20:48  Demo\ch01\ch01\obj

     目录          0  2009-08-18 20:48  Demo\ch01\ch01\Properties

............此处省略6个文件信息

评论

共有 条评论