看到一段代码,如下(.net2.0中)
private static string[] autoCompleteWordList = null;
[WebMethod]
public String[] GetCompleteList(string prefixText, int count)
{
if (autoCompleteWordList == null)
{
string[] temp = File.ReadAllLines(Server.MapPath("~/TextFile.txt"));
Array.Sort(temp, new CaseInsensitiveComparer());
autoCompleteWordList = temp;
} int index = Array.BinarySearch(autoCompleteWordList, prefixText, new CaseInsensitiveComparer());
if (index < 0)
{
index = ~index;
} int matchingCount;
for (matchingCount = 0; matchingCount < count && index + matchingCount < autoCompleteWordList.Length; matchingCount++)
{
if (!autoCompleteWordList[index + matchingCount].StartsWith(prefixText, StringComparison.CurrentCultureIgnoreCase))
{
break;
}
}
String[] returnValue = new string[matchingCount];
if (matchingCount > 0)
{
Array.Copy(autoCompleteWordList, index, returnValue, 0, matchingCount);
}
return returnValue;
}
请问
index = ~index;
这是什么意思, 我好像都没见过这用法
顺便问一下,Server.MapPath("~/TextFile.txt"));这“~/”的写法,在.net1.1中好像没有
望大虾赐教
private static string[] autoCompleteWordList = null;
[WebMethod]
public String[] GetCompleteList(string prefixText, int count)
{
if (autoCompleteWordList == null)
{
string[] temp = File.ReadAllLines(Server.MapPath("~/TextFile.txt"));
Array.Sort(temp, new CaseInsensitiveComparer());
autoCompleteWordList = temp;
} int index = Array.BinarySearch(autoCompleteWordList, prefixText, new CaseInsensitiveComparer());
if (index < 0)
{
index = ~index;
} int matchingCount;
for (matchingCount = 0; matchingCount < count && index + matchingCount < autoCompleteWordList.Length; matchingCount++)
{
if (!autoCompleteWordList[index + matchingCount].StartsWith(prefixText, StringComparison.CurrentCultureIgnoreCase))
{
break;
}
}
String[] returnValue = new string[matchingCount];
if (matchingCount > 0)
{
Array.Copy(autoCompleteWordList, index, returnValue, 0, matchingCount);
}
return returnValue;
}
请问
index = ~index;
这是什么意思, 我好像都没见过这用法
顺便问一下,Server.MapPath("~/TextFile.txt"));这“~/”的写法,在.net1.1中好像没有
望大虾赐教
解决方案 »
- 请问这样的文件上传程序该如何写?
- 怎么才能执行else语句块里面的代码!
- asp.net2.0中是不是没有input image html控件
- 本人菜鸟,提一个master页面的问题
- 紧急请教!为什么站点发布到服务器上报500错误!!
- 用asp.net(c#)实现检索.html文件内容,并且将文件列表列出显示,请教高手啊!
- 问一个页面调用的简单问题。。。。请大家看看
- 请教与web用户控件的交互问题,按照MSDN与CSDN以往的解答均未成功
- 为什么现在很多的企业系统(b/s)都只支持IE?
- select 嵌套写法的执行顺序,在线等..........
- 为什么calendar控件选择日期后会跳回至这个月的日期
- 页面中如何输出中文状态下的数字呢?
index = ~index;
是按位取“非”