小编Vam*_*msi的帖子

如何在C#中使用Internet Explorer属性窗口

我正在开发一个Windows应用程序,我必须为用户提供一种通过打开IE设置窗口来更改代理设置的方法.Google Chrome使用相同的方法,当您尝试更改Chrome中的代理设置时,它将打开Internet Explorer选项卡属性窗口并选择连接选项卡.

我观察到chrome正在运行run32dll.exe来实现这一点,但它也传递了一些参数

System.Diagnostics.Process.Start("rundll32.exe", "SomeArgumentsHere");

我唯一的问题是我不知道它传递了什么参数.

为了简化我的问题,我想知道从我的C#.net应用程序中选择连接选项卡打开IE设置窗口的方法

更新以下代码,为我工作

System.Diagnostics.Process.Start("inetcpl.cpl", ",4");
Run Code Online (Sandbox Code Playgroud)

c# settings internet-explorer

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

如何在 C# 中使用 HtmlAgilityPack 获取 HTML 元素的内容?

我想使用 C# 中的 HTMLAgilityPack 从 HTML 页面获取有序列表的内容,我尝试了以下代码,但是,这不起作用任何人都可以帮忙,我想传递 html 文本并获取第一个有序列表的内容在html中找到

private bool isOrderedList(HtmlNode node)
{
    if (node.NodeType == HtmlNodeType.Element)
    {
        if (node.Name.ToLower() == "ol")
            return true;
        else
            return false;
    }
    else
        return false;
}

public string GetOlList(string htmlText)
{
    string s="";
    HtmlDocument doc = new HtmlDocument();
    doc.LoadHtml(htmlText);
    HtmlNode nd = doc.DocumentNode;
    foreach (HtmlNode node in nd.ChildNodes)
    {
        if (isOrderedList(node))
        {
            s = node.WriteContentTo();
            break;
        }
        else if (node.HasChildNodes)
        {
            string sx= GetOlList(node.WriteTo());
            if (sx != "")
            {
                s = sx;
                break; …
Run Code Online (Sandbox Code Playgroud)

html c# html-parsing html-agility-pack

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

在后台工作线程中使用C#全局变量是否安全

嗨,我正在研究一个简单的桌面应用程序,它需要处理一些操作,如加载可能阻塞主线程的网页,所以我将代码移动到后台工作者.

我的问题是有一个名为UCSProject的繁重类,它包含许多字符串和List字段,我需要将此类的实例传递给后台worker,因为该类有点重,我想减少重复次数实例直接使用全局变量,而不是将其作为参数传递给后台工作者.

为了简短起见,我只想知道从C#中的后台工作线程访问全局变量是否安全

c# multithreading backgroundworker thread-safety

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

哪个表现最好:经典ASP,ASP.NET WebForms还是ASP.NET MVC?

我最近将一个经典的asp应用程序转换为ASP.NET 3.5,但我觉得我的经典ASP版本有点快(我不知道可能是买家的悔意).

所以你们可以帮助我,让我知道哪一个更快,asp,asp.net或ASP.NET MVC.

我一直在搜索这个问题而没有找到任何东西,如果你发现任何问题,请指出这个问题并将我的问题标记为重复

感谢你们.

asp.net asp.net-mvc performance asp-classic

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

为什么在C#中声明为隐式类型的数字默认为整数?

例1

var test = Byte.MaxValue;
Console.WriteLine(test + " : " + test.GetType().Name);
Run Code Online (Sandbox Code Playgroud)

结果255:字节

例2

var test = 255;
Console.WriteLine(test + " : " + test.GetType().Name);
Run Code Online (Sandbox Code Playgroud)

结果255:Int32

例3

var test = 10;
Console.WriteLine(test + " : " + test.GetType().Name);
Run Code Online (Sandbox Code Playgroud)

结果10:Int32

例4

var test = 255;
test = Int64.MaxValue;  
Console.WriteLine(test + " : " + test.GetType().Name);
Run Code Online (Sandbox Code Playgroud)

结果:错误:无法将类型long隐式转换为int

我的问题是为什么C#在使用时默认类型为Int32 var.

c# var implicit-typing

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

如何轻松地创建一个类的接口?

我有一个有10种方法的课.我想要的是创建该类的接口,即接口将只包含这10个方法的签名.

可以使用Visual Studio在.NET中轻松完成吗?

我问的是这个问题,因为我正在改变我的项目架构,对于我项目中的每个班级,我都需要一个界面.

c# refactoring interface class automated-refactoring

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

使用A星查找路径的启发式函数

我正在尝试为以下问题找到最佳解决方案 在此输入图像描述

  1. 每个节点内表示的数字表示为(x,y).
  2. 节点的相邻节点总是具有y(当前节点y值+1)的值.
  3. x当我们从一个节点到另一个节点时,值的变化为1
  4. 如果没有值的变化,从节点到其相邻节点没有成本x.
  5. 没有2个具有相同y值的节点被认为是相邻的.

最优解是成本最低的解决方案,我正在考虑使用A*路径寻找算法来寻找最优解.

我的问题,A*是这类问题的一个很好的选择,或者我应该看看任何其他算法,而且我还在考虑使用递归方法来计算启发式成本,但我感觉它不是好主意.

这是我如何认为启发式函数将是这样的例子

  • 节点的启发式权重= Min(它的子节点的启发式权重)
  • 子节点也是如此.

但就我所知,启发式意味着是一种近似,所以我认为就启发式函数而言,我的方向是错误的

algorithm heuristics a-star path-finding graph-algorithm

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

如何在VB.net中获取当前类或Method中的变量名类型和值?

嗨,我正在开发一个项目,我的类必须执行用户提供的VB代码,使其变得简单我正在尝试重新创建我自己的eval函数,我使用下面的代码,我在网上找到这个任务

Imports Microsoft.VisualBasic
Imports System
Imports System.Text
Imports System.CodeDom.Compiler
Imports System.Reflection
Imports System.IO
Namespace PAB.Util
    Public Class EvalProvider

        Public Function VS_Eval(ByVal vbCode As String) As Object

            Dim c As VBCodeProvider = New VBCodeProvider
            Dim icc As ICodeCompiler = c.CreateCompiler()
            Dim cp As CompilerParameters = New CompilerParameters

            cp.ReferencedAssemblies.Add("system.dll")
            cp.ReferencedAssemblies.Add("system.xml.dll")
            cp.ReferencedAssemblies.Add("system.data.dll")
            ' Sample code for adding your own referenced assemblies
            'cp.ReferencedAssemblies.Add("c:\yourProjectDir\bin\YourBaseClass.dll")
            'cp.ReferencedAssemblies.Add("YourBaseclass.dll")
            cp.CompilerOptions = "/t:library"
            cp.GenerateInMemory = True
            Dim sb As StringBuilder = New StringBuilder("")
            sb.Append("Imports System" & vbCrLf)
            sb.Append("Imports System.Xml" & …
Run Code Online (Sandbox Code Playgroud)

vb.net reflection

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

如何创建引用复合主键中一列的外键

我有两个表Catalog和CatalogIndex

目录包含以下列

DN
PID
PURL
Desc
Run Code Online (Sandbox Code Playgroud)

其中两列DN,PID是此表的复合主键的一部分.

CatalogIndex具有以下列

PID
PItem
PVal
Run Code Online (Sandbox Code Playgroud)

PID和PItem是CatalogIndex表的复合主键的一部分.

我想在PID列上添加一个foriegn键到CatalogIndex,它引用了Catalog表中的PID.

我正在使用SQL Server 2008

谢谢

sql-server sql-server-2008 composite-primary-key

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

使用C#将DateTime插入SQL Server

我是C#ADO.NET和SQL的新手,有一个我无法想象的问题.我正在尝试DateTime使用C#插入SQL Server.我收到了消息

"从字符串转换日期和/或时间时转换失败"

当程序命中时cmd.ExecuteNonQuery();.对此的任何帮助真的很感激

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using AutoLotConnectedLayer;
using System.Configuration;
using System.Data;

namespace AutoLotCUIClient
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("***** The AutoLot Console UI *****\n");

            // Get connection string from App.config.
            string cnStr =
              ConfigurationManager.ConnectionStrings["AutoLotSqlProvider"].ConnectionString;
            //bool userDone = false;
            //string userCommand = "";

            // Create our InventoryDAL object.
            InventoryDAL invDAL = new InventoryDAL();
            invDAL.OpenConnection(cnStr);

            InsertNewCar(invDAL);

 #region Insert car
        private static void InsertNewCar(InventoryDAL invDAL)
        {
            // First …
Run Code Online (Sandbox Code Playgroud)

c#

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