出于某种原因,只添加垂直滚动条适用于我的代码.
我似乎无法添加一个垂直和水平滚动条.
private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox1.ScrollBars = ScrollBars.Vertical;
}
Run Code Online (Sandbox Code Playgroud) 我想忽略蓝色框中的部分并开始从箭头中读取我的txt文件

我打算只循环前8行并将它们存储在垃圾变量中.如果我这样做,我的crusor现在是在第9行,所以我可以从那里开始阅读?我的代码肯定是错的,它甚至没有读取前8行.
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
StreamReader sr = new StreamReader(File.OpenRead(ofd.FileName));
for (int i = 0; i < 8; i++)
{
string junk = sr.ReadLine();
}
sr.Dispose();
}
}
Run Code Online (Sandbox Code Playgroud) 运算符'!='不能应用于'string []'和'string'类型的操作数(是的我之前已经问过类似的问题,我看过一个,但是使用的上下文/元素是不同类型的,所以我'我很感激帮助我的情况:))
我有一个文件,我想在文件中以"0"开头的一行后立即停止阅读.我的while循环遇到了不等式运算符的问题.
private void button1_Click(object sender, EventArgs e)
{
// Reading/Inputing column values
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string[] lines = File.ReadAllLines(ofd.FileName).Skip(8).ToArray();
textBox1.Lines = lines;
while (lines != "0") // PROBLEM Happens Here
{
int[] pos = new int[3] { 0, 6, 18 }; //setlen&pos to read specific colmn vals
int[] len = new int[3] { 6, 12, 28 }; // only doing 3 columns right now
foreach (string line in textBox1.Lines)
{
for …Run Code Online (Sandbox Code Playgroud) 背景+问题:
(Begginer here)我想用我的c#代码中的列表中的值填充sqlite db.这是从finisarsqlite网站获取的sqlite代码:我通过创建自己的列名称来修改它,如"seq#"等.
但我收到以下错误:"无法识别的令牌#"
也许我的语法已关闭?
码:
// [snip] - As C# is purely object-oriented the following lines must be put into a class:
// We use these three SQLite objects:
SQLiteConnection sqlite_conn;
SQLiteCommand sqlite_cmd;
SQLiteDataReader sqlite_datareader;
// create a new database connection:
sqlite_conn = new SQLiteConnection("Data Source=database.db;Version=3;New=True;Compress=True;");
// open the connection:
sqlite_conn.Open();
// create a new SQL command:
sqlite_cmd = sqlite_conn.CreateCommand();
// Let the SQLiteCommand object know our SQL-Query:
sqlite_cmd.CommandText = "CREATE TABLE table1 (Seq# integer primary key, …Run Code Online (Sandbox Code Playgroud)