class Program
{
static void Main(string[] args)
{
SizeClass sizeClass = new SizeClass(){Width = 10, Length = 10};
Console.WriteLine("赋值前:width={0},length={1}", sizeClass.Width, sizeClass.Length);
var copyOfSizeClass = sizeClass;
copyOfSizeClass.Length = 5;
copyOfSizeClass.Width = 5;
Console.WriteLine("赋值后:width={0},length={1}",sizeClass.Width, sizeClass.Length);
Console.ReadKey();
}
}
public class SizeClass
{
public int Width { get; set; }
public int Length { get; set; }
}
public struct SizeStruct
{
public int Width { get; set; }
public int Length { get; set; }
}
class Program
{
static void Main(string[] args)
{
SizeStruct sizeStruct = new SizeStruct(){Length = 10, Width = 10};
Console.WriteLine("赋值前:width={0},length={1}", sizeStruct.Width, sizeStruct.Length);
var copyOfSizeStruct = sizeStruct;
copyOfSizeStruct.Length = 5;
copyOfSizeStruct.Width = 5;
Console.WriteLine("赋值后:width={0},length={1}", sizeStruct.Width, sizeStruct.Length);
Console.ReadKey();
}
}
class Program
{
static void Main(string[] args)
{
List<string> temp = new List<string>(){"my","god"};
temp.ForEach(t => Console.Write(t + " "));
Console.ReadKey();
}
public static void ChangeReferenceType(List<string> list)
{
list = new List<string>(){"hello", "world"};
}
}
class Program
{
static void Main(string[] args)
{
List<string> temp = new List<string>(){"my","god"};
ChangeReferenceType(temp);
temp.ForEach(t => Console.Write(t + " "));
Console.ReadKey();
}
public static void ChangeReferenceType(List<string> list)
{
list.Clear();
list.Add("hello");
list.Add("world");
}
}
class Program
{
static void Main(string[] args)
{
Size s = new Size(){Length = 10, Width = 10};
ChangeStructType(s);
Console.Write("Length={0},Width={1}", s.Length,s.Width);
Console.ReadKey();
}
public static void ChangeStructType(Size size)
{
size.Length = 0;
size.Width = 0;
}
}
public struct Size
{
public int Length { get; set; }
public int Width { get; set; }
}
class Program
{
static void Main(string[] args)
{
Room r = new Room()
{
TableSize = new Size(){Length = 100, Width = 80},
TvSize = new Size(){Length = 10, Width = 8}
};
r.TableSize.Length = 0;
Console.WriteLine("table目前的尺寸是:length={0},width={1}", r.TableSize.Length, r.TableSize.Width);
Console.ReadKey();
}
}
public struct Size
{
public int Length { get; set; }
public int Width { get; set; }
}
public struct Room
{
public Size TableSize { get; set; }
public Size TvSize { get; set; }
}
r.TableSize.Length = 0;
r.TableSize = new Size(){Length = 0, Width = 0};
class Program
{
static void Main(string[] args)
{
var oneSize = new Size() {Length = 10, Width = 10};
var twoSize = oneSize;
oneSize.Changed += (s, e) => Console.Write("Size发生了改变~~");
oneSize.Length = 0;
Console.ReadKey();
}
}
public class Size
{
private int _length;
private int _width;
public event System.EventHandler Changed;
public int Length
{
get { return _length; }
set
{
_length = value;
OnChanged();
}
}
public int Width
{
get { return _width; }
set { _width = value; OnChanged(); }
}
private void OnChanged()
{
if (Changed != null)
{
Changed(this, new EventArgs());
}
}
}
public struct Room
{
public Size TableSize { get; set; }
public Size TvSize { get; set; }
}
class Program
{
static void Main(string[] args)
{
var size = new SizeStruct();
Console.WriteLine("length={0},width={1}", size.Length, size.Width);
Console.ReadKey();
}
}
public struct SizeStruct
{
public int Length { get; set; }
public int Width { get; set; }
}
class Program
{
static void Main(string[] args)
{
var size = new SizeClass();
Console.WriteLine("length={0},width={1}", size.Length, size.Width);
Console.ReadKey();
}
}
public class SizeClass
{
public int Length { get; set; }
public int Width { get; set; }
public SizeClass(int length, int width)
{
Length = length;
Width = Width;
}
}
public struct SizeStruct
{
public int _length = 10;
}
public struct SizeStruct
{
public int _length;
public SizeStruct()
{
_length = 10;
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有