public class SeqList<int> // 此句错误 ??
{
public SeqList<int> sqList;
public int getLength()
{
sqList.getLength();
} public int BinarySearch(SeqList<int> sqList, int key)
{
sqList[0] = key; //存放要查找的记录
int mid = 0;
int flag = -1;// 标志
int low = 1; //设置初始区间的下限值
int high = sqList.getLength(); // 设置初始区间的上限值 //记录没有查找完
while (low <= high)
{
//middle
mid =( low + high)/2;
if (sqList[0] == sqList[mid])
{
flag = mid;// search successful ,then save record to flag 's
break;
}
else if (sqList[0] < sqList[mid])
{ // left binary area
high = mid - 1; }
else { // right binary area
low = mid + 1;
} }
if (flag > 0)
{
Console.WriteLine("search is successful");
return flag;
}
else
{
Console.WriteLine("search is failed ");
return -1;
} }
}
错误 1 类型参数声明必须是标识符,不能是类型 C:\Inetpub\wwwroot\StrigDs\StrigDs\Form2.cs 73 26 StrigDs
public class SeqList<int> // 此句错误 ??
{
public SeqList<int> sqList;
public int getLength()
{
sqList.getLength();
} public int BinarySearch(SeqList<int> sqList, int key)
{
sqList[0] = key; //存放要查找的记录
int mid = 0;
int flag = -1;// 标志
int low = 1; //设置初始区间的下限值
int high = sqList.getLength(); // 设置初始区间的上限值 //记录没有查找完
while (low <= high)
{
//middle
mid =( low + high)/2;
if (sqList[0] == sqList[mid])
{
flag = mid;// search successful ,then save record to flag 's
break;
}
else if (sqList[0] < sqList[mid])
{ // left binary area
high = mid - 1; }
else { // right binary area
low = mid + 1;
} }
if (flag > 0)
{
Console.WriteLine("search is successful");
return flag;
}
else
{
Console.WriteLine("search is failed ");
return -1;
} }
}
错误 1 类型参数声明必须是标识符,不能是类型 C:\Inetpub\wwwroot\StrigDs\StrigDs\Form2.cs 73 26 StrigDs
public class SeqList<int> // 此句错误 ??
解决方案 »
- C#屏蔽Ctrl+Alt+Del,求完美解决办法.
- 讨论数值比较算法 性能问题
- 关于读取word文档表格内容
- 请问关于ItemCheck
- 引发了“System.ArgumentNullException”类型的异常
- 我用JS做了个级联,但是前台读取XML,考虑到XML太大了,所以我决定将在后台读取XML,然后讲读出来的仍到前台来绑定下拉框,怎么实现将后台读取的XML扔到JS里面处理?
- 还是老问题,模拟网页登陆
- 大家帮我看看这段代码,treeview的遍历问题
- 求助grid
- InvokeMember打开Word文档另存为Html页,如何先关闭Html,再退出Word?(后台代码实现)
- 权限模块设计完毕,发出来大家交流~
- 请问ToolStripMenuItem.Image 属性如何设置?
public class SeqList <T>
{
public SeqList <T> sqList;
public int getLength()
{
sqList.getLength();
} public int BinarySearch(SeqList <T> sqList, int key)
{
sqList[0] = key; //存放要查找的记录
int mid = 0;
int flag = -1;// 标志
int low = 1; //设置初始区间的下限值
int high = sqList.getLength(); // 设置初始区间的上限值 //记录没有查找完
while (low <= high)
{
//middle
mid =( low + high)/2;
if (sqList[0] == sqList[mid])
{
flag = mid;// search successful ,then save record to flag 's
break;
}
else if (sqList[0] < sqList[mid])
{ // left binary area
high = mid - 1; }
else { // right binary area
low = mid + 1;
} }
if (flag > 0)
{
Console.WriteLine("search is successful");
return flag;
}
else
{
Console.WriteLine("search is failed ");
return -1;
} }
}
Error :
sqList[0] = key; //此句错误????????????
Program: public class SeqList <T>
{
public SeqList <T> sqList; public SeqList <T> GetLength()
{
return sqList.GetLength();
} public int BinarySearch(SeqList <T> sqList, int key)
{
sqList[0] = key; //存放要查找的记录
int mid = 0;
int flag = -1;// 标志
int low = 1; //设置初始区间的下限值
int high = Convert.ToInt32(sqList.GetLength()); // 设置初始区间的上限值 //记录没有查找完
while (low <= high)
{
//middle
mid = (low + high) / 2;
if (sqList[0] == sqList[mid])
{
flag = mid;// search successful ,then save record to flag 's
break;
}
else if (sqList[0] < sqList[mid])
{ // left binary area
high = mid - 1; }
else
{ // right binary area
low = mid + 1; } }
if (flag > 0)
{
Console.WriteLine("search is successful");
return flag;
}
else
{
Console.WriteLine("search is failed ");
return -1;
} }
}