list内存如何分配啊 不够用 但是list不是每次添加动态重新分配的么??
解决方案 »
- 如何讲控件自带的右击菜单替换成我弄的右击菜单呢? 或者在该菜单上添加一些内容呢??
- 关于参数防止SQL注入
- 新建一个DataTable类的过程好像很复杂,如何简洁地新建一个两列都是字符串,或第二列是可选字符串组(有没有这东西?)的DataTable?
- C#中怎么在mousemove函数中绘制连续的圆
- 200+列数据库操作
- 征集API在C#或VB.NET中的应用方法及其代码示例
- 文本编辑器
- 高分请教C# window中的排版问题!!
- DataSet 数据分组成多个DataSet
- 萌新求帮忙
- size与location的问题
- [100分]如何使用工具反汇编系统dll,比如MessageBox.Show这个函数
报错是对这一句报错的
我对valuelist只执行add操作啊
treeview_data_result.AddRange(GainTreeViewValue(s[3]));这句也报
但是这些我感觉都不是主要问题啊 不应该错的
List<string> valueList = new List<string>();
// valueList.
string color_Rusult,modelling_Result,shell_Result;
HCS.Open_Segment(pathString);
{
int count = 0;
StringBuilder color_type = new StringBuilder(4096);
StringBuilder color_value = new StringBuilder(4096);
float color_r = new float();
float color_g = new float();
float color_b = new float();
HCS.Begin_Contents_Search(pathString, "COLOR");
HCS.Show_Contents_Count(out count);
while (HCS.Find_Contents(color_value, out count))
{
if (color_value.ToString().Trim() == "color")
HCS.Show_Color_By_Value(color_value, color_type, out color_r, out color_g, out color_b); }
HCS.End_Contents_Search();
color_Rusult ="COLOR <"+ color_value.ToString() + color_type.ToString() + "r=" + color_r.ToString() +"g=" + color_g.ToString() + "b="+color_b.ToString()+">";
//For Modelling_Matrix
StringBuilder model_value = new StringBuilder(4096);
float[] modelling_value = new float[16];
HCS.Begin_Contents_Search(pathString, "MODELLING MATRIX");
HCS.Show_Contents_Count(out count);
while (HCS.Find_Contents(model_value, out count))
{
if (model_value.ToString() == "modelling matrix")
{
HCS.Show_Modelling_Matrix(modelling_value);
}
}
HCS.End_Contents_Search();
//valueList.Add(modelling_value.ToString());
modelling_Result = "MODELLING MATRIX <";
for (int i = 0; i < modelling_value.Length; i++)
{
modelling_Result += modelling_value[i].ToString();
modelling_Result += " ";
}
modelling_Result += ">";
//For Shell
StringBuilder geometry_value = new StringBuilder(4096);
StringBuilder lod_value = new StringBuilder(4096);
HCS.Begin_Contents_Search(pathString, "GEOMETRY");
int shell_Point=0, shell_Tristrips=0, shell_Face=0, shell_Number, shell_Key = 0;// lod_lvl = 0;
int[] shell_Face_value = new int[4096];
float[] shell_Point_Value = new float[4096];
HCS.Show_Contents_Count(out count);
while (HCS.Find_Contents(geometry_value, out count))
{
if (geometry_value.ToString() == "shell")
{
HCS.Show_Shell_Face_Count(count, out shell_Face);
HCS.Show_Shell_Tristrip_Count(count, out shell_Tristrips);
HCS.Show_Shell(count, out shell_Point, shell_Point_Value, out shell_Number, shell_Face_value);
shell_Key = HCS.KInsert_Shell(shell_Point, shell_Point_Value, shell_Face, shell_Face_value);
}
}
shell_Result = shell_Key.ToString("X")+ "-"+"Ponits:"+shell_Point.ToString()+","+shell_Face.ToString()+"Faces in"+shell_Tristrips.ToString()+"tristrips";
HCS.End_Contents_Search();
valueList.Add("~");
valueList.Add(color_Rusult);
valueList.Add("~");
valueList.Add(modelling_Result);
valueList.Add("~");
valueList.Add("GEOMETRY");
valueList.Add("$");
valueList.Add("SHELL");
valueList.Add("%");
valueList.Add(shell_Result);
就报错了?
valueList.Add(color_Rusult);
valueList.Add("~");
valueList.Add(modelling_Result);
valueList.Add("~");
valueList.Add("GEOMETRY");
valueList.Add("$");
valueList.Add("SHELL");
valueList.Add("%");
valueList.Add(shell_Result);
问题 多
那么当第一次调用Add方法的时候,系统就会为List分配4个位置的大小。而超过4个则分配8个,超过8个就分配16个。也就是说,假设你添加了2049个值进去,那么实际分配的空间大小就是4096。分配5万个进去,就会分配65536个。额外多出来不少。
你这是new List<string> List是你自己写的嘛??不然你怎么可以去new interface???