Click here to Skip to main content
15,898,036 members
Home / Discussions / C#
   

C#

 
QuestionCVS with big C# Winforms project Pin
jesarg20-Sep-07 11:44
jesarg20-Sep-07 11:44 
AnswerRe: CVS with big C# Winforms project Pin
Paul Conrad23-Sep-07 6:42
professionalPaul Conrad23-Sep-07 6:42 
QuestionMultiple files through context menu Pin
Johan Martensson20-Sep-07 10:40
Johan Martensson20-Sep-07 10:40 
QuestionDesign pattern framework Pin
Wes Aday20-Sep-07 10:29
professionalWes Aday20-Sep-07 10:29 
AnswerRe: Design pattern framework Pin
Pete O'Hanlon20-Sep-07 10:44
mvePete O'Hanlon20-Sep-07 10:44 
GeneralRe: Design pattern framework Pin
Wes Aday20-Sep-07 11:04
professionalWes Aday20-Sep-07 11:04 
GeneralRe: Design pattern framework Pin
Pete O'Hanlon20-Sep-07 11:18
mvePete O'Hanlon20-Sep-07 11:18 
Questioneasy newbie question - SOLVED [modified] Pin
shwaguy20-Sep-07 10:27
shwaguy20-Sep-07 10:27 
I get the following error when running my code:

"A local variable named 'textOut' cannot be declared in this scope because it would give a different meaning to 'textOut', which is already used in a 'child' scope to denote something else"


namespace file_i_o<br />
{<br />
    public partial class Form1 : Form<br />
    {<br />
        public Form1()<br />
        {<br />
            InitializeComponent();<br />
        }<br />
<br />
        private void button1_Click(object sender, EventArgs e)<br />
        {<br />
            string path = @"c:\testc.txt";<br />
            try<br />
            {<br />
<br />
                StreamWriter textOut = new StreamWriter(new FileStream(path, FileMode.Create, FileAccess.Write));<br />
                <br />
            }<br />
           <br />
            catch(IOException ioe)<br />
            {<br />
                MessageBox.Show(ioe.Message);<br />
            }<br />
                StreamWriter textOut = new StreamWriter(new FileStream(path, FileMode.Create, FileAccess.Write));<br />
                textOut.Write("test"); //*****THIS IS WHERE MY ERROR IS*****<br />
                textOut.Close();<br />
        }<br />
    }<br />
}



If I put the "textOut.Write("test");" code in my try statement all is fine.
I think this sucks; I found that I cannot reuse textOut anywhere else in my code, this just does not seem right!

Please help and enlighten me.

Many Thanks,

Stuntman



-- modified at 18:06 Thursday 20th September, 2007
AnswerRe: easy newbie question Pin
lost in transition 20-Sep-07 10:31
lost in transition 20-Sep-07 10:31 
GeneralRe: easy newbie question Pin
Scott Dorman20-Sep-07 10:38
professionalScott Dorman20-Sep-07 10:38 
GeneralRe: easy newbie question Pin
lost in transition 20-Sep-07 10:47
lost in transition 20-Sep-07 10:47 
GeneralRe: easy newbie question Pin
Scott Dorman20-Sep-07 10:51
professionalScott Dorman20-Sep-07 10:51 
AnswerRe: easy newbie question Pin
Scott Dorman20-Sep-07 10:36
professionalScott Dorman20-Sep-07 10:36 
GeneralRe: easy newbie question Pin
Pete O'Hanlon20-Sep-07 11:26
mvePete O'Hanlon20-Sep-07 11:26 
GeneralRe: easy newbie question Pin
Scott Dorman20-Sep-07 11:32
professionalScott Dorman20-Sep-07 11:32 
AnswerRe: easy newbie question Pin
shwaguy20-Sep-07 12:06
shwaguy20-Sep-07 12:06 
QuestionGridView Row updating Pin
ss.mmm20-Sep-07 9:57
ss.mmm20-Sep-07 9:57 
QuestionPerformanceCounter problems Pin
JMichael246820-Sep-07 8:53
JMichael246820-Sep-07 8:53 
AnswerRe: PerformanceCounter problems Pin
JMichael246821-Sep-07 4:36
JMichael246821-Sep-07 4:36 
QuestionSpeed up Treeview [Solved] Pin
DaveyM6920-Sep-07 8:52
professionalDaveyM6920-Sep-07 8:52 
AnswerRe: Speed up Treeview Pin
Dave Kreskowiak20-Sep-07 9:12
mveDave Kreskowiak20-Sep-07 9:12 
GeneralRe: Speed up Treeview Pin
DaveyM6920-Sep-07 10:55
professionalDaveyM6920-Sep-07 10:55 
GeneralRe: Speed up Treeview Pin
Scott Dorman20-Sep-07 10:58
professionalScott Dorman20-Sep-07 10:58 
GeneralRe: Speed up Treeview Pin
DaveyM6920-Sep-07 11:13
professionalDaveyM6920-Sep-07 11:13 
AnswerRe: Speed up Treeview [modified] Pin
Scott Dorman20-Sep-07 10:56
professionalScott Dorman20-Sep-07 10:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.