Monday, May 27, 2013

run once block

string some_text;
string file = "test.txt";
// Run once and break where necessary
do
{
    // If no file then SKIP
    if (!File.Exists(file))
        break;
        
    if (any_condition_to_skip)
        break;

    // Sample code to execute
    using (StreamReader sr = new StreamReader(file))
    {
        some_text = sr.ReadToEnd();
    }

// Run once
} while (false);            

No comments:

Post a Comment