所以我有这门课
namespace WindowsFormsApplication2
{
public class Records
{
public string name, surname;
public int num;
}
}
Run Code Online (Sandbox Code Playgroud)
我想创建一个这个类的数组,尝试了一切,它仍然无法工作,我开始认为这是一个错误,我使用Visual Studio 2012,这是我的代码.任何帮助将不胜感激.
(表单上有一个记录的数据网格,我从文本框中读取,信息与制表符分开)
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Records[] userRecs = new Records[20];
public int count = 0;
private void Form1_Load(object sender, EventArgs e)
{
getText();
}
public void getText()
{
FileStream fs = new FileStream("D:\\filestr.txt",FileMode.Open);
StreamReader sr = new StreamReader(fs);
for (string readed = sr.ReadLine(); readed != null; readed = sr.ReadLine()) …Run Code Online (Sandbox Code Playgroud) 我试图取消选中菜单中所有可检查的ToolStripMenuItem项目
foreach (ToolStripMenuItem item in filtersMenu.DropDownItems)
{
item.Checked = false;
}
Run Code Online (Sandbox Code Playgroud)
ToolStripMenuItem都可以检查,但问题是编译器给出了InvalidCastException,循环也试图对ToolStripSeparator项目进行操作,如何解决这个问题,任何帮助都将不胜感激,谢谢.