小编Mik*_*ike的帖子

如何在树视图中获取当前选定的节点

如何在树视图中获取所选(单击)节点并将其作为字符串返回?

.net c# windows winforms

2
推荐指数
1
解决办法
4万
查看次数

用C#选中数组的某些字符串

我试图在数组中选择paticular字符串并将它们添加到一个新数组中,例如我想获取包含.txt和.rtf的数组中的所有字符串,并将它们添加到新数组中,例如filteredStrings []

.net c# windows

2
推荐指数
1
解决办法
150
查看次数

正则表达困扰C#

尝试使用以下正则表达式时遇到问题:

string profileConfig = File.ReadAllText(str);

string startIndex = "user_pref(\"network.proxy.autoconfig_url\", \"";
string endIndex = "\"";

var regex = startIndex + "(.*)" + endIndex;
// Here we call Regex.Match.
Match match = Regex.Match(profileConfig, 
                          regex,
                          RegexOptions.IgnoreCase);

// Here we check the Match instance.
if (match.Success)
{
    // Finally, we get the Group value and display it.
    string key = match.Groups[1].Value;
    MessageBox.Show(key);
}
Run Code Online (Sandbox Code Playgroud)

我收到错误:

附加信息:解析"user_pref("network.proxy.autoconfig_url","(.*)"" - 还不够).

我的正则表达式在某种程度上是否格式错误?

.net c# windows

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

客户端无法访问类(xxxxx):无法在@INC - PERL中找到xxxxx.pm

我正在尝试运行Perl SOAP服务器,它启动正常,但是当远程调用方法时,我收到以下消息:

SOAP :: Serializer :: envelope:客户端无法访问类(HELLO):无法在(eval 127)第3行的@INC(@INC contains :)中找到HELLO.pm.

现在我假设这是因为@INC没有指定我的HELLO.pm文件所在的位置?虽然我可以在哪里定义这个?我已经尝试将以下内容添加到我的脚本并将类(Hello.pm)放在那里,但没有运气:

BEGIN {
  push(@INC, '/etc/perl/');
};
Run Code Online (Sandbox Code Playgroud)

我的代码如下(soapserver.pl):

BEGIN {
  push(@INC, '/etc/perl/');
};
#- SoapHttpServerTrace.pl
#- Copyright (c) 2002 by Dr. Herong Yang
   use SOAP::Lite +trace;
   use SOAP::Transport::HTTP;
   my $daemon = SOAP::Transport::HTTP::Daemon
      -> new (LocalAddr => 'XX.XX.XX.XX', LocalPort => 8001, listen => 5);
   $daemon -> dispatch_to('Hello::hello');
   print "Contact SOAP server at ", $daemon->url, "\n";
   $daemon->handle();
Run Code Online (Sandbox Code Playgroud)

perl soap

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

用Java剪切/分割字符串

我有一个字符串如下:

2012/02/01,13:27:20,872226816,-1174749184,2136678400,2138578944,-17809408,2147352576
Run Code Online (Sandbox Code Playgroud)

我想提取数字:872226816,所以在这种情况下我假设在第二个逗号开始读取数据之后,然后以下逗号结束读取数据.

示例输出:

872226816
Run Code Online (Sandbox Code Playgroud)

java

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

输出数组列表的内容

如何将arraylist中的值返回到屏幕上,例如System.out.println

我在想一个for循环,例如

for (String s : list)
{
    System.out.println(s);
}
Run Code Online (Sandbox Code Playgroud)

但它抱怨它无法将对象转换为字符串 - 如何将其转换为字符串?

码:

public static void GetStatsProc(String operation)
{
     try { 
        Process p=Runtime.getRuntime().exec(operation); 
        p.waitFor(); 
        BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream())); 
        String line=reader.readLine(); 
        while(line!=null) 
        { 
            // Add all lines into an array
            ArrayList list = new ArrayList();
            list.add(line);
            System.out.println(line); 
            line=reader.readLine(); 
        } 

     }
     catch(IOException e1) {}
     catch(InterruptedException e2) {}   
}
Run Code Online (Sandbox Code Playgroud)

java

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

检查文件的行与正则表达式

我正在使用Regex.Match方法在文件中查找信用卡号(用于PCI合规性)

我通过文件的行(strLine)进行交互,并检查每个文件与正则表达式(m_strRegEx):

Regex.Match(strLine, m_strRegEx)

string strLine = "4111111111111111"
Run Code Online (Sandbox Code Playgroud)

这工作正常,但如果该行包含其他字符,例如strLine可能=:

string strLine = "fhj*4111111111111111op)"
Run Code Online (Sandbox Code Playgroud)

正则表达式然后没有选择cc号码,怎么可能克服这个问题?

我正在使用的正则表达式是:

^4[0-9]{12}(?:[0-9]{3})?$
Run Code Online (Sandbox Code Playgroud)

.net c# regex windows

-1
推荐指数
1
解决办法
131
查看次数

'string'不包含'TryParse'b的定义

我试图在文本文件中获取一个值(在一个名为#Hostname的行下).当主机名纯粹是一个整数(int.TryParse),这曾经工作,但现在我使用的是一个字符串(string.TryParse)我无法得到它,因为"'string'不包含'TryParse'的定义"我还能用什么吗?

   private void GetGeneralConfig()
    {
        // lets grabs the info from the config!
        var lines = File.ReadAllLines("general_settings.ini");
        var dictionary = lines.Zip(lines.Skip(1), (a, b) => new { Key = a, Value = b })
                              .Where(l => l.Key.StartsWith("#"))
                              .ToDictionary(l => l.Key, l => l.Value);
        // lets define variables and convert the string in the dictionary to int for the sock.connection method!
        string.TryParse(dictionary["#Hostname"], out hostname);

    }
Run Code Online (Sandbox Code Playgroud)

.net c# windows

-2
推荐指数
1
解决办法
1067
查看次数

标签 统计

.net ×5

c# ×5

windows ×5

java ×2

perl ×1

regex ×1

soap ×1

winforms ×1