List<String> strList =newList<String>
for(int i =0; i<strList.Count; i++)
{
strList.RemoveAt(i);
}
List<String> strList =newList<String>
for(int i =0; i<strList.Count; i++)
{
strList.RemoveAt(i);
i-=1;
}
public const String str="First Version";
Int32 a=3; Object obj=new object(); //这里装箱成功,不会失败 obj=i; //拆箱一定会失败 Int64 b=(Int64)obj;
Int64 b =(Int64)(Int32)obj;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UseOperator
{
class Program
{
static void Main(string[] args)
{
Test t1 = new Test();
t1.MyFun();
Console.ReadLine();
}
}
class Test
{
public void MyFun()
{
Test t = new Test();
if (t == null)
{
Console.WriteLine("t为空!");
}
else
{
Console.WriteLine("t不为空!");
}
}
//存在BUG的重载运算法
public static bool operator ==(Test t1, Test t2)
{
return t2.Equals(t1);
}
public static bool operator !=(Test t1, Test t2)
{
return !(t1 == t2);
}
//覆盖HashCode
public override int GetHashCode()
{
return base.GetHashCode();
}
public override bool Equals(object obj)
{
return base.Equals(obj);
}
}
}
public static bool operator ==(Test t1, Test t2)
{
if ((t2 as object) == null)
{
return (t1 as object) == null;
}
else
{
return t2.Equals(t1);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FransferVirtualFunction
{
class Program
{
static void Main(string[] args)
{
try
{
Child ch = new Child();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.Read();
}
}
public class Ref
{
public string Str = "这是Ref类的一个成员";
}
public class Parent
{
protected Ref my;
public Parent()
{
my = new Ref();
//构造方法中调用了虚方法
Console.WriteLine(GetString());
}
//虚方法
public virtual string GetString()
{
return my.Str; //使用了内部成员
}
}
public class Child : Parent
{
private Ref my2;
public Child()
: base()
{
my2 = new Ref();
}
//重写虚方法
public override string GetString()
{
return my2.Str; //使用了内部成员
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有