Here is the code I've been playing with to load a text file into a TextBox control (don't laugh - I've only been doing C# for twenty five minutes)
private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (OpenDialog.ShowDialog() == DialogResult.OK) { TextBox.Clear(); String[] Temp = TextBox.Lines; using(StreamReader S=new StreamReader(OpenDialog.OpenFile())) { String line; int N=0; while((line=S.ReadLine())!=null) { Array.Resize(ref Temp, N + 1); Temp[N] = line; N = N + 1; } TextBox.Lines = Temp; } } }
Help! I've got no idea what I'm doing!
Do you lot reckon I'd be better to start off with some C# console applications until I'm comfortable with the language? Will the Windows Forms stuff make a bit more sense?
I reckon from a few recent conversations that if I can learn C# fairly quickly, there may be quite a lot of work round my way in programming. I'm sick and tired of sales and want to write programs for a living now.
Anyone got any good links to C# tutorials as well? I haven't really looked myself yet but I'd like to know which ones you lot recommend.
Ta.
Sorry, I can't help much with the actual code. It looks fine to me but then I haven't done much text stuff with C# yet. However, I reckon you should be able to dump the file into a string in one go... In any case, the best examples and documentation I found (was pointed to) came with Visual Studio itself. Press F1. I found the class libraries pretty good.