我是C#的新手,因此可能这是一个非常简单的问题,但即使在我阅读完所有内容后,我仍无法找到添加Visual Studio 2010所需定义的方法,尽管在每个表达式的MSDN文档页面上添加using语句和引用。添加引用后不包含定义
我的错误:
System.windows.forms does not contain a definition for document
我加入基于什么我读了微软网站上的参考“presentationframework”。感谢下面的一些评论,我发现我显然混合了两种不同的方式从文本框中获取文本。我需要做的就是将内容粘贴到文本框中,并在按下按钮时获取框的内容。有人可以告诉我(或更好地显示)我如何做到这一点,而不是混合策略?
Form1.cs中:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Documents;
using System.Windows.Controls.RichTextBox;
using System.Windows.Forms;
using System.Windows.Controls;
using System.Collections;
namespace WindowsFormsApplication1
{
public partial class HackController : Form
{
ArrayList ipList = new ArrayList();
ArrayList acctList = new ArrayList();
int myAcct = 0;
string myIp = "";
public HackController()
{
InitializeComponent();
}
public void sync_Click(object sender, EventArgs e)
{
string data = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd).Text;// ERROR HERE
string[] lines = Regex.Split(data, "\n");
Regex ipMatch = new Regex(@"\d+.\d+.\d+.\d+");
Regex acctMatch = new Regex(@"#\d+");
foreach(string line in lines)
{
foreach(Match m in ipMatch.Matches(line))
{
ipList.Add(m);
}
foreach(Match m in acctMatch.Matches(line))
{
acctList.Add(m);
}
}
}
}
}
它是'.Split'还使用本地结构'字符串'作为字符串 – Sam 2014-09-13 18:13:04
尝试删除'using System.Windows.Forms;','rtb'应该是'System.Windows.Controls.RichTextBox'而不是'System。 Windows.Forms.RichTextBox' – 2014-09-13 18:27:52
@YuliamChandra,我试着做你的建议,但它没有解决我的问题。如果我删除.Forms我碰到我的pulic部分类错误....我会更新我的代码,以包括整个班级 – Rilcon42 2014-09-13 18:43:30