📄 class.cs
字号:
namespace PGTMergePictures
{
public class ObjArray
{
//对象数组
private object[] Items;
//对象数组的长度
public int Length
{
get
{
if (Items == null)
return 0;
else
return Items.Length;
}
}
/// <summary>
/// 构造函数
/// </summary>
public ObjArray()
{
//
// TODO: 在此处添加构造函数逻辑
//
Items = null;
}
/// <summary>
/// 添加一元素
/// </summary>
/// <param name="item">元素</param>
public void addItem(object item)
{
if (Items == null)
{
Items = new object[1];
Items[0] = item;
return;
}
else
{
object[] tmpList = new object[Length + 1];
for (int i = 0; i < Length; i++)
{
tmpList[i] = Items[i];
}
tmpList[Length] = item;
Items = tmpList;
return;
}
}
/// <summary>
/// 删除一个元素
/// </summary>
/// <param name="index">元素索引</param>
public void deleteItem(int index)
{
if (Items == null)
return;
else
{
//如果索引没有越界
if (index >= 0 && index < Length && Length > 1)
{
object[] tmpList = new object[Length - 1];
for (int i = 0; i < index; i++)
{
tmpList[i] = Items[i];
}
for (int i = index + 1; i < Length; i++)
{
tmpList[i - 1] = Items[i];
}
Items = tmpList;
return;
}
else
{
if (index == 0 && Length <= 1)
{
Items = null;
return;
}
else
return;
}
}
}
/// <summary>
/// 读取元素
/// </summary>
/// <param name="index">元素索引</param>
/// <returns>一个元素</returns>
public object getItem(int index)
{
if (Items == null)
return null;
else
{
if (index >= 0 && index < Length)
return Items[index];
else
return null;
}
}
/// <summary>
/// 清空数组
/// </summary>
public void clearAll()
{
Items = null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -