以下代码中的以下行不会产生任何影响:
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) 我想读取文件但不是从文件的开头但是在文件的特定位置.例如,我想在文件开头之后读取977个字符后的文件,然后一次读取接下来的200个字符.谢谢.
我想创建一个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) 为了让这个工作变得更好,我一直都很疯狂.
我的代码中有几个类.我将尝试在下面发布相关代码并尽可能缩短
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#中评估SQL语句以确定它是否不仅仅是选择的最佳方法是什么? - 即 - 如果稍后执行该语句,则检查是否将更改值(插入,更新,删除,修改或删除).
我可以使用的开箱即用C#dlls/functions的任何想法,或者这是我应该使用字符串解析技术编写自己的东西?
谢谢.
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?
我只是没有得到它.欢迎任何帮助.谢谢.艺术
我有一个C#API,可以采用相同类型的0/1 /多个参数.什么应该是更好的方法来定义API = params与IEnumerable<T>?
我试图将此代码从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) 我有一个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函数的方法.