TreeNode上IEnumerator的有效参数是什么?
我在这一行得到了错误:
IEnumerator ie = tn.Nodes.GetEnumerator();
Run Code Online (Sandbox Code Playgroud)
在这个方法中:
private void parseNode(TreeNode tn)
{
IEnumerator ie = tn.Nodes.GetEnumerator();
string parentnode = "";
parentnode = tn.Text;
while (ie.MoveNext())
{
TreeNode ctn = (TreeNode)ie.Current;
if (ctn.GetNodeCount(true) == 0)
{
_nodeToString += ctn.Text;
}
else
{
_nodeToString += "<" + ctn.Text + ">";
}
if (ctn.GetNodeCount(true) > 0)
{
parseNode(ctn);
}
}
_nodeToString += "</" + parentnode + ">";
_nodeToString += "\n";
}
Run Code Online (Sandbox Code Playgroud) 这是在我的 sample.html 里面
<html>
<head>
<title>Test</title>
</head>
<body>
<div id="testingID">hello</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我在 c# 中有这段代码,我想提示的是div元素内的世界“hello” ,id 为testingID
private void btnGetData_Click(object sender, EventArgs e)
{
string url = string.Format("{0}/sample.html", Environment.CurrentDirectory);
WebBrowser webb = new WebBrowser();
webb.Navigate(url);
var doc = webb.Document;
HtmlElement elem = doc.GetElementById("testingID");
MessageBox.Show(elem.InnerText);
}
Run Code Online (Sandbox Code Playgroud)
但我得到的对象引用未设置为对象的实例。在MessageBox.Show(elem.InnerText);
这里有一点帮助..
我有这个字符串
This is a <143>sample</143> regex <143>pa<665>t</665>tern</143> selection <143>by</143> tags in <128>c#</128> and my <132>name</132> is <175>Vincent</175>
Run Code Online (Sandbox Code Playgroud)
而我本来应该通过标签来获得比赛.我用它来突出文字.
预期产量:
<143>sample</143>
<143>pa<665>t</665>tern</143>
<665>t</665>
<143>by</143>
<128>c#</128>
<132>name</132>
<175>Vincent</175>
Run Code Online (Sandbox Code Playgroud)
我尝试了这个正则表达式模式:
<(143|128|132|175)>.*</(143|128|132|175)>
Run Code Online (Sandbox Code Playgroud)
但它会将所有结果打印为匹配,整个字符串.
请帮忙.
跟进问题
而不是获得整行匹配,我可以单独获取标签内的文本吗?就像我只是得到样本而不是<143>样本<`/ 143>
我只是想听听我对使用NAudio的麦克风的说法,这是我的代码到目前为止,但问题是我听不到任何声音.任何帮助,将不胜感激.
public partial class frmMain : Form
{
private WaveIn waveIn; // Gets an audio from microphone
private WaveOut waveOut; // Sends audio to speaker
private BufferedWaveProvider waveProvider; // Gets an audio from stream
public frmMain()
{
InitializeComponent();
}
private void frmMain_Load(object sender, EventArgs e)
{
waveOut = new WaveOut();
waveIn = new WaveIn();
waveProvider = new BufferedWaveProvider(waveIn.WaveFormat);
waveOut.Init(waveProvider);
waveIn.DataAvailable += waveIn_DataAvailable;
waveOut.Play();
}
private void waveIn_DataAvailable(object sender, WaveInEventArgs e)
{
waveProvider.Read(e.Buffer, 0, e.BytesRecorded);
}
private void btnStop_Click(object sender, EventArgs …Run Code Online (Sandbox Code Playgroud) 有没有其他方法在PHP中打印40个点?
我有这个想法,但我觉得这是错的..也许有这样的方式.
<?php print(".",40); ?>
Run Code Online (Sandbox Code Playgroud)
有可能这样做吗?没有使用循环..?
我不知道这个代码有什么问题..它说字符串无法转换为对象..类似的东西..
//lvLogs <-- ListView (2 colums)
Hashtable serverLogs = new Hashtable();
serverLogs.Add("a", "aw");
serverLogs.Add("b", "ew");
serverLogs.Add("c", "iw");
foreach (DictionaryEntry h in serverLogs)
{
lvLogs.Items.Add(h.Key).SubItems.Add(h.Value);
}
Run Code Online (Sandbox Code Playgroud)
但是这段代码工作得很好..
Hashtable serverLogs = new Hashtable();
serverLogs.Add("a", "aw");
serverLogs.Add("b", "ew");
serverLogs.Add("c", "iw");
foreach (DictionaryEntry h in serverLogs)
{
//lvLogs.Items.Add(h.Key).SubItems.Add(h.Value);
//lvi.SubItems.Add(h.Value);
lvLogs.Items.Add(h.Key + " - " + h.Value);
}
Run Code Online (Sandbox Code Playgroud)
如何从lvLogs中的列中分离键和值?
我遇到了这个GetEnumerator问题..这是我的情况
Panel eachPanel = new Panel();
eachPanel.Size = new Size(pnlProcessCon.Width - 27, 24);
eachPanel.Location = new Point(5, startPoint);
eachPanel.BackColor = (defaultColor == alterColor[0]) ? alterColor[1] : alterColor[0];
TextBox txtProcess = new TextBox();
txtProcess.Size = new Size(50, 20);
txtProcess.Location = new Point(2,2);
txtProcess.TextAlign = HorizontalAlignment.Center;
txtProcess.Text = "P" + Convert.ToString(startProcess);
TextBox txtBurstTime = new TextBox();
txtBurstTime.Size = new Size(50, 20);
txtBurstTime.Location = new Point(txtProcess.Right + 70, 2);
txtBurstTime.TextAlign = HorizontalAlignment.Center;
TextBox txtPriority = new TextBox();
txtPriority.Size = new Size(50, 20);
txtPriority.Location …Run Code Online (Sandbox Code Playgroud) 这是我在richtextbox1里面的字符串集..
/Category/5
/Category/4
/Category/19
/Category/22
/Category/26
/Category/27
/Category/24
/Category/3
/Category/1
/Category/15
http://example.org/Category/15/noneedtoadd
Run Code Online (Sandbox Code Playgroud)
我想用" http://example.com/ "之类的网址更改所有的起始"/ "
输出:
http://example.com/Category/5
http://example.com/Category/4
http://example.com/Category/19
http://example.com/Category/22
http://example.com/Category/26
http://example.com/Category/27
http://example.com/Category/24
http://example.com/Category/3
http://example.com/Category/1
http://example.com/Category/15
http://example.org/Category/15/noneedtoadd
Run Code Online (Sandbox Code Playgroud)
只是问,那是什么模式?:)
c# ×7
regex ×2
collections ×1
javascript ×1
naudio ×1
php ×1
sockets ×1
tree-nodes ×1
winforms ×1