小编ggc*_*des的帖子

从C#网站获取HTML代码

如何从网站获取HTML代码,保存它,并通过LINQ表达式查找一些文本?

我正在使用以下代码来获取网页的来源:

public static String code(string Url)
{
    HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(Url);
    myRequest.Method = "GET";
    WebResponse myResponse = myRequest.GetResponse();
    StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);
    string result = sr.ReadToEnd();
    sr.Close();
    myResponse.Close();

    return result;
 }
Run Code Online (Sandbox Code Playgroud)

如何在网页源中的div中找到文本?

html c# linq

79
推荐指数
5
解决办法
28万
查看次数

如何正确解码cmd输出?

ProcessStartInfo startInfo = new ProcessStartInfo("CMD.exe");
startInfo.Arguments = "/c " + URL;
Process p = new Process();
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.CreateNoWindow = true;
p = Process.Start(startInfo);
string original = p.StandardOutput.ReadToEnd();
string result1 = Encoding.ASCII.GetString(Encoding.ASCII.GetBytes(original));
string result2 = Encoding.BigEndianUnicode.GetString(Encoding.BigEndianUnicode.GetBytes(original));
string result3 = Encoding.Unicode.GetString(Encoding.Unicode.GetBytes(original));
string result4 = Encoding.UTF32.GetString(Encoding.UTF32.GetBytes(original));
string result5 = Encoding.UTF7.GetString(Encoding.UTF7.GetBytes(original));
string result6 = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(original));
Run Code Online (Sandbox Code Playgroud)

cmd输出包含俄语字母,无法使用我尝试的所有编码正确解码.请帮忙.

我试过了:

startInfo.StandardOutputEncoding = Encoding."all possible encodings";
Run Code Online (Sandbox Code Playgroud)

但没有帮助.

有任何想法吗?

c# cmd

9
推荐指数
3
解决办法
1万
查看次数

继承和泛型

我有一个应用程序,在节点和边G(N,E)的图形上执行各种分析算法.节点和边的属性随应用程序而变化,并根据图的类型和属性的性质形成继承层次结构.例如,Node层次结构的根可以表示最一般的非定向循环图(NcgNode).NcgNode的子类可以表示有向循环图(DcgNode),然后是DagNode等.可以应用于DAG的算法与NCG的算法不同,但反之亦然.树的根的关键行为是添加和检索图的相邻节点.问题是如何在不创建"未经检查"的异常的情况下执行此操作?

代码的简洁版本可能如下所示:

import java.util.ArrayList;
import java.util.List;

public class NcgNode {
    private List<NcgNode> nodeList_ = null;
    private List<? extends NcgNode> nodeListSrc_ = null;
    private List<? super NcgNode> nodeListSink_ = null;

    public <N extends NcgNode> void addNode(N node) {
        if (nodeList_ == null) {
            nodeList_ = new ArrayList<NcgNode>();
            nodeListSrc_ = nodeList_;
            nodeListSink_ = nodeList_;
        }
        nodeListSink_.add(node);
    }

    @SuppressWarnings("unchecked")
    // Any way to avoid this?
    public <N extends NcgNode> N getNode(int n) {
        if ((nodeList_ == null) || (n >= nodeList_.size()))
            return null; …
Run Code Online (Sandbox Code Playgroud)

java generics inheritance

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

水平滚动条

如果内容在边框中溢出,如何在页面中创建自动水平滚动条.

<html>
     <body>
        <div style ="width: 20px; height:30px; border:1px solid black; overflow:auto">
            <!-- various of text here that can makes it go out the border-->
        </div>  
     </body>
</html>
Run Code Online (Sandbox Code Playgroud)

如果我的内容中的文字太长,如何制作自动水平滚动条怎么办?

html css scrollbar

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

错误:聚合'第一个'的类型不完整,无法定义

我写了这个头文件(header1.h):

#ifndef HEADER1_H
#define HEADER1_H

class first ;

//int summ(int a , int b) ;



#endif
Run Code Online (Sandbox Code Playgroud)

和这个源文件(header1.cpp and main.cpp):

#include <iostream>
#include "header1.h"

using namespace std;


class first
{
    public:
  int a,b,c;
  int sum(int a , int b);

};

  int first::sum(int a , int b)
{

    return a+b;
}
Run Code Online (Sandbox Code Playgroud)

 

#include <iostream>
#include "header1.h"


using namespace std;


   first one;

int main()
{
   int j=one.sum(2,4);
    cout <<  j<< endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但是当我运行这个程序时codeblocks,我给出了这个错误:

聚合'第一个'具有不完整的类型,无法定义.

c++ codeblocks

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

无法将lambda表达式转换为委托类型

我正在尝试从SQL数据库中获取第一个用户,该用户Entity model正在与已经存在的数据库进行通信,该数据库具有我正在寻找的用户的用户ID.出现此错误和第二个错误.

无法将lambda表达式转换为委托类型,System.Func<iomnientitylibrary.user,bool>因为块中的某些返回类型不能隐式转换为委托返回类型.

无法隐式转换intbool.

public user GetUser(int userID)
{
     using (var context = new iomniEntities())
    {
        user u = context.users.FirstOrDefault(user => user.userID);

        return u;
    }
}
Run Code Online (Sandbox Code Playgroud)

context.users.ToList()工作正常,但我不想那么低效.

sql linq entity-framework visual-studio-2010

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

'Module'的类型初始值设定项引发了异常

有一个c ++/cli项目,它是一个Windows应用程序.在调试模式下,我们没有任何问题,但在将其带到释放模式后,此错误启动.我搜索并找到了一些论坛答案,但无法帮助我解决这个问题.

请帮我 ....

错误:

An unhandled exception of type 'System.TypeInitializationException' occurred in Unknown Module
Run Code Online (Sandbox Code Playgroud)

附加信息:" Module " 的类型初始化程序引发了异常.

c++ c++-cli

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