我搜索了很多,但都猜到了答案.帮我找到确切的答案.
我需要一个非常简单的例子来了解事件.我感觉很难理解互联网或书籍中的例子.
using System;
using System.Collections;
namespace Iterator_test
{
class Day
{
int days_idx = -1;
private String[] days = { "mon", "tue", "wed","thu","fri","sat","sun" };
public IEnumerable getdays()
{
days_idx++;
yield return days[days_idx];
}
}
class Program
{
static void Main(string[] args)
{
Day d = new Day();
foreach (string day in d.getdays())
{
Console.WriteLine(day);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
实际上输出应该是,
mon
tue
wed
thu
fri
sat
sun
Run Code Online (Sandbox Code Playgroud)
但它的打印只是"mon",
mon
Run Code Online (Sandbox Code Playgroud)
会是什么原因?
可以在c#.net中使用多个迭代器(对于单个类或对象)吗?如果是给我一些简单的例子.对不起,如果问题不明白,请告诉我.
我正在尝试使用perl脚本在浏览器中打印XML文件.当我尝试在浏览器中运行脚本时,我遇到以下错误.
Server error!
The server encountered an internal error and was unable to complete your request.
Error message:
Premature end of script headers: get_data.pl
If you think this is a server error, please contact the webmaster.
Error 500
localhost
01/15/10 14:29:28
Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1
Run Code Online (Sandbox Code Playgroud)
这是我的脚本.我也使用语法检查器检查了语法.我的perl配置没问题,因为其他简单的perl脚本工作正常.我认为问题在于"使用CGI"; 引导我..
#!/usr/local/bin/perl -w
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $r = new CGI();
my $id = $r->param('id');
if(!defined($id))
{
print "Content-type: text/html\n\nMissing parameter: id\n";
exit 1;
}
if($id eq …Run Code Online (Sandbox Code Playgroud)