小编Bri*_*sen的帖子

String.Replace在运行时不替换字符串

以下代码中的以下行不会产生任何影响:

string1.Replace(string1.Substring(firstchar, lastchar - firstchar), "##");
Run Code Online (Sandbox Code Playgroud)

string1 保持不变,使用IndexOf时返回相同的索引.

while (firstchar != string1.LastIndexOf("test"))
{

    firstchar = string1.IndexOf("test");
    lastchar = string1.IndexOf(" ");
    using (StreamWriter writer = new StreamWriter("C:\\textfile1.txt"))
    {
        writer.WriteLine(string1.Substring(firstchar, lastchar - firstchar));
        writer.WriteLine();
        writer.Dispose();
    }
    string1.Replace(string1.Substring(firstchar, lastchar - firstchar), "##");

}
Run Code Online (Sandbox Code Playgroud)

.net c# string

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

如何从C#中的特定光标点开始读取文件?

我想读取文件但不是从文件的开头但是在文件的特定位置.例如,我想在文件开头之后读取977个字符后的文件,然后一次读取接下来的200个字符.谢谢.

c# file-io writing file

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

从链接列表中删除节点

我想创建一个delete_node函数,它将列表中位置的节点删除为第一个节点的计数.到目前为止,这是我的代码:

class node:
    def __init__(self):
        self.data = None # contains the data
        self.next = None # contains the reference to the next node

class linked_list:
    def __init__(self):
        self.cur_node = None

    def add_node(self, data):
        new_node = node() # create a new node
        new_node.data = data
        new_node.next = self.cur_node # link the new node to the 'previous' node.
        self.cur_node = new_node #  set the current node to the new one.

    def list_print(self):
        node = ll.cur_node
        while node:
            print node.data
            node = node.next …
Run Code Online (Sandbox Code Playgroud)

python linked-list

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

当BindingList中的现有项发生更改时,Listbox拒绝更新

为了让这个工作变得更好,我一直都很疯狂.

我的代码中有几个类.我将尝试在下面发布相关代码并尽可能缩短

public class ServerSettings
{
    private BindingList<Server> serverList = new BindingList<Server>();

    public ServerSettings()
    {

    }

    private void readSettings()
    {           
        string list = "/Settings/Server";
        XmlNodeList Xn = settings.SelectNodes(list);

        foreach (XmlNode xNode in Xn)
        {
            Server tmpSrv = new Server();
            for (int i=0; i<xNode.ChildNodes.Count; i++)
            {
                if(xNode.ChildNodes[i].Name == "Name")
                    tmpSrv.Name = xNode.ChildNodes[i].InnerText;
                else if(xNode.ChildNodes[i].Name == "Host")
                    tmpSrv.Host = xNode.ChildNodes[i].InnerText;
                else if(xNode.ChildNodes[i].Name == "Username")
                    tmpSrv.Username = xNode.ChildNodes[i].InnerText;
                else if(xNode.ChildNodes[i].Name == "Password")
                    tmpSrv.Password = xNode.ChildNodes[i].InnerText;
            }
            tmpSrv.ID = xNode.Attributes["ID"].Value;
            serverList.Add(tmpSrv);
        }
    }

    public …
Run Code Online (Sandbox Code Playgroud)

c# listbox bindinglist

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

C#向后兼容性

  1. 我正在使用运行.net 4.0的Windows 7
  2. 我在我的平台上写了一个应用程序,然后将它分发给我的同事.
  3. 他们使用的是Windows XP .net 3.0和3.5
  4. 出于商业原因,他们无法更新到.net 4.
  5. 我正在运行Visual Studio 2010

如何使我的应用程序向后兼容以便他们可以使用它?

.net c# backwards-compatibility

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

在C#中评估sql语句的最佳方法是什么?

在C#中评估SQL语句以确定它是否不仅仅是选择的最佳方法是什么? - 即 - 如果稍后执行该语句,则检查是否将更改值(插入,更新,删除,修改或删除).

我可以使用的开箱即用C#dlls/functions的任何想法,或者这是我应该使用字符串解析技术编写自己的东西?

谢谢.

c# sql dll

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

F#WPF MouseMove参数

canvas.MouseMove.Add(move canvas update)

MouseMove.Add( p1 p2 p3)
Run Code Online (Sandbox Code Playgroud)

通常我会看到这个用法和文档,两个参数 - (对象发送者,MouseEventArgs e) - 我在这个示例代码中采用移动和画布,取自F#.NET Journal的计算几何:快速外壳.

更新一些delagate?或将气泡信息路由到MouseMove.Add?

我只是没有得到它.欢迎任何帮助.谢谢.艺术

wpf user-interface msdn f#

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

API的参数数组与IEnumerabl e <T>

我有一个C#API,可以采用相同类型的0/1 /多个参数.什么应该是更好的方法来定义API = paramsIEnumerable<T>

c#

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

从C#转换为VB的问题

我试图将此代码从C#转换为VB.试图使用第三方工具,但没有成功.有人可以帮助我.谢谢

private static string RemoveInvalidHtmlTags(this string text)
{
    return HtmlTagExpression.Replace(text, new MatchEvaluator((Match m) =>
    {
        if (!ValidHtmlTags.ContainsKey(m.Groups["tag"].Value))
            return String.Empty;

        string generatedTag = String.Empty;

        System.Text.RegularExpressions.Group tagStart = m.Groups["tag_start"];
        System.Text.RegularExpressions.Group tagEnd = m.Groups["tag_end"];
        System.Text.RegularExpressions.Group tag = m.Groups["tag"];
        System.Text.RegularExpressions.Group tagAttributes = m.Groups["attr"];

        generatedTag += (tagStart.Success ? tagStart.Value : "<");
        generatedTag += tag.Value;

        foreach (Capture attr in tagAttributes.Captures)
        {
            int indexOfEquals = attr.Value.IndexOf('=');

            // don't proceed any futurer if there is no equal sign or just an equal sign
            if (indexOfEquals < 1)
                continue; …
Run Code Online (Sandbox Code Playgroud)

c# vb.net

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

如何在我的C#类中运行jQuery?

我有一个ASP.NET MVC项目,我想在它们上使用jQuery.另外提到我把jQuery放在head部分,发现它们可以在firebug中工作.

现在我想在我的C#类中使用jQuery.我如何在C#类中使用它们.我想运行代码,但它永远不会编译我出错的地方.

 public class Manager
    {
        public static void Test()
        {
          // i put here jQuery code but they never compiler i try many time.
        }
    }
Run Code Online (Sandbox Code Playgroud)

在C#类中使用jQuery的正确方法是什么.就像在javascript代码中工作,如果我写,但在c#当我想尝试类似ajax请求.

$ .ajax在javascript中运行良好,但是当我想在C#中运行它们时,它们无法编译.从c#类发送ajax请求的正确方法是什么.

请告诉我在c#类中使用jQuery ajax函数的方法.

c# ajax jquery http request

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