小编rup*_*610的帖子

从子程序返回数组

我试图从数组中返回数据.代码如下:

my %ignorables = map { $_ => 1 } qw([notice mpmstats: rdy bsy rd wr ka log dns cls bsy: in);

open my $error_fh, '<', 'iset_error_log';

sub findLines {

    # Iterates over the lines in the file, putting each into $_
    while (<$error_fh>) {

        # Only worry about the lines containing [notice
        if (/\[notice/) {

            if (/\brdy\b/){
                print "\n";
            }
            else {
                print ",";
            }

            # Split the line into fields, separated by spaces, skip the %ignorables
            my @line …
Run Code Online (Sandbox Code Playgroud)

perl subroutine

0
推荐指数
2
解决办法
3万
查看次数

随机化下一页

我有一个在每个页面上都有问题的应用程序.目前我有一个按钮,其中OnClick指向下面的功能,但我希望它选择一个随机页面.我有10个.aspx页面.我怎样才能做到这一点?

protected void newWindow(object sender, EventArgs e)
    {
        Response.Redirect("Question2.aspx");
    }
Run Code Online (Sandbox Code Playgroud)

c# asp.net

0
推荐指数
1
解决办法
77
查看次数

Foreach循环File.Readlines不显示任何内容

我有一个foreach循环,当我点击一个按钮时,它应该显示来自txt文件的行.单击按钮时没有显示任何内容.我究竟做错了什么?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Main(object sender, EventArgs e)
        {
            foreach (string line in File.ReadLines(@"C:\Users\Matt\Desktop\AirportCodes2.txt"))
            {
                if (line.Contains("Chicago"))
                {
                    Console.WriteLine(line);
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

文本文件以制表符分隔,格式如下:

芝加哥IL ORD奥黑尔国际

c# foreach readlines

0
推荐指数
1
解决办法
1372
查看次数

标签 统计

c# ×2

asp.net ×1

foreach ×1

perl ×1

readlines ×1

subroutine ×1