我有两个webmethods.首先是:
void deleteFile(string filePath)
{
File.Delete(filePath);
}
Run Code Online (Sandbox Code Playgroud)
另一个是:
string[] getAllFile()
{
// at the same folder....
Directory.GetFiles("*.xml");
.....
return ....
}
Run Code Online (Sandbox Code Playgroud)
我这样称呼这些方法:
deleteFile("1.xml")
getAllFile();
Run Code Online (Sandbox Code Playgroud)
尽管删除了"1.xml"文件,但调用Directory.GetFiles("*.xml");仍会在结果中返回"1.xml".换句话说,它似乎没有被删除.
然后,当我循环结果时,尝试读取文件,获取FileNoFoundException
我做了如下↓的测试
1)创建客户枚举(从每周的复制)
[Serializable]
public enum Tester
{
// ??:
// Indicates Sunday.
Sunday = 0,
//
// ??:
// Indicates Monday.
Monday = 1,
//
// ??:
// Indicates Tuesday.
Tuesday = 2,
//
// ??:
// Indicates Wednesday.
Wednesday = 3,
//
// ??:
// Indicates Thursday.
Thursday = 4,
//
// ??:
// Indicates Friday.
Friday = 5,
//
// ??:
// Indicates Saturday.
Saturday = 6,
}
Run Code Online (Sandbox Code Playgroud)
2)创建两种测试方法......
static void TestEnumToString()
{
var t = Tester.Sunday;
Enumerable.Range(0, …Run Code Online (Sandbox Code Playgroud) 如果一个解决方案中有很多项目,并且每个项目都有很多.cs文件.此外,一个文件中可能还有一个类.
所以,我想问的问题是:如何快速找到文件或类?
我真的不喜欢ctrl+F每次使用.
是否有任何插件,如果我点击CTRL+SHIFT+R它将打开一个显示类列表或文件列表的窗口,我可以输入我想要找到的关键字.
然后,当我双击结果时,将为我打开文件.
样品....
SampleClass:
public class SampleClass
{
public delegate void BeforeEditorHandle();
public event BeforeEditorHandle OnBeforeEditor;
}
Run Code Online (Sandbox Code Playgroud)
MainMethod
static void Main(string[] args)
{
SampleClass sc = new SampleClass();
// Add Event
sc.OnBeforeEditor +=new SampleClass.BeforeEditorHandle(sc_OnBeforeEditor);
// Remove Event
sc.OnBeforeEditor -= new SampleClass.BeforeEditorHandle(sc_OnBeforeEditor);
}
Run Code Online (Sandbox Code Playgroud)
并且,如果我像这样动态添加事件...↓
sc.OnBeforeEditor += () => { };
Run Code Online (Sandbox Code Playgroud)
我应该删除像↓这样的事件
sc.OnBeforeEditor -= () => { };
Run Code Online (Sandbox Code Playgroud)
但是,如果我在活动中有太多的消息来源,我认为这非常难看......有人能告诉我最好的方法来取消活动吗?
例如,我有一个类如下:
public class SampleItem
{
public string QCD { get; set; }
public string CCD { get; set; }
public string ITYPE { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
然后,我有一个清单:
var lstTest = new List<SampleItem>() {
new SampleItem(){ QCD = "Q1" , CCD = "C1" , ITYPE = "A"} ,
new SampleItem(){ QCD = "Q1" , CCD = "C2" , ITYPE = "A"} ,
new SampleItem(){ QCD = "Q1" , CCD = "C3" , ITYPE = "A"} ,
new SampleItem(){ QCD = …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
class SampleClass : IDisposable
{
public void Dispose()
{
Console.WriteLine("Execute Dispose!");
}
}
static void Main(string[] args)
{
SampleClass sc = new SampleClass();
try
{
throw new Exception();
}
finally
{
sc.Dispose();
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行它时,它不会打印Execute Dispose!消息,为什么会这样?
更新:
如果我像这样更改了代码:
static void Main(string[] args)
{
SampleClass sc = new SampleClass();
try
{
try
{
throw new Exception();
}
finally
{
sc.Dispose();
}
}
catch
{
throw;
}
}
Run Code Online (Sandbox Code Playgroud)
它首先打印消息然后崩溃.
我的想法是,如果应用程序崩溃,它可以随意处理吗?
我知道这很简单,但我真的要学到更多东西.
class Program
{
static void Main(string[] args)
{
Test(0);
}
static void Test(int i)
{
if (i > 30000)
{
return;
}
Test(i + 1);
}
}
Run Code Online (Sandbox Code Playgroud)
为什么在调用上面的示例时获取递归函数并抛出StackOverflowException.
(因为超过默认的递归堆栈大小?)
但我想知道如何解决这个问题.
谢谢.
我的源代码使用csharp进行ip检查.
现在,我必须考虑关于ipv4和ipv6的检查规则.
客户端可能像↓
?only ipv4
?only ipv6
?both ipv4 and ipv6
Run Code Online (Sandbox Code Playgroud)
对不起,我是网络新手.
因此,有人可以给我一些关于ip检查的建议吗?
谢谢.
关于IP检查:
我现在有一张像↓这样的支票:
bool isgoodip()
{
return ip.startwith(173);
}
Run Code Online (Sandbox Code Playgroud)
如果客户端只有ipv6,我该如何进行检查呢?
并且,是否有服务器设置可以将ipv6转换为ipv4 auto?
<html>
<div>
<ul>
<li><a>a</a></li>
<li><a>b</a></li>
<li><a>c</a></li>
<li><a>d</a></li>
</ul>
<ul>
<li><a>e</a></li>
<li><a>f</a></li>
<li><a>g</a></li>
<li><a>h</a></li>
</ul>
<ul>
<li><a>i</a></li>
<li><a>j</a></li>
<li><a>k</a></li>
<li><a>l</a></li>
</ul>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
alert($("div a:first-child").text());
$("div").each(function(){
alert($(this).find("a:first-child").text());
});
});
</script>
</html>
Run Code Online (Sandbox Code Playgroud)
我想得到div中的第一个""元素
但我尝试了两种方式,如下所示,无法得到它.
有人可以教我吗?
<script type="text/javascript">
$(function(){
alert($("div a:first-child").text());
$("div").each(function(){
alert($(this).find("a:first-child").text());
});
});
</script>
Run Code Online (Sandbox Code Playgroud)