• [Tips]:值类型和引用类型的一个例子


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                string[] a = { "a", "b", "c", "d" };
                var b = a.SingleOrDefault(c => c.Equals("b"));
                b = "hello world";
                if (a[1] == "hello world")
                {
                    Console.Out.WriteLine("true");
                }
                else
                {
                    Console.Out.WriteLine("false");
                }
                Console.ReadLine();
                List<Person> allPersons = new List<Person>{ 
                    new Person{ Name="Jack"},
                    new Person{ Name="Crystal"}
                };
                Person p=new Person();
                p = allPersons.SingleOrDefault(c => c.Name == "Crystal");
                p.Name = "Tom";
                foreach (var item in allPersons)
                {
                    Console.Out.WriteLine(item.Name);                
                }
                Console.ReadLine();
           }
        }
        public class Person
        {
            public string Name { get; set; }
        }
    }
    
    结果:
    
    
    image 
  • 相关阅读:
    JSON 语法
    AJAX 原理与使用
    SpringMVC MVC 架构模式
    HTTP 协议
    OSI 七层参考模型与 TCP/IP 四层协议
    MyBatis 延迟加载(十四)
    关于JVM调优
    mysql的锁
    spring boot启动原理
    redis相关问题解决
  • 原文地址:https://www.cnblogs.com/cnblogsfans/p/1528663.html
Copyright © 2020-2023  润新知