Wednesday, August 18, 2010

#2 Usings

Just not to forget, that there could be multiple objects in a using statement:
using (Font font3 = new Font("Arial", 10.0f),
      font4 = new Font("Arial", 10.0f))
{
  // Use font3 and font4.
}

* This source code was highlighted with Source Code Highlighter.

Though, all objects should be of the same type, the following is not allowed:
using (IEnumerator<T1> firstEnumerator = first.GetEnumerator(),
    IEnumerator<T2> secondEnumerator = second.GetEnumerator())
{
  // ...
}


* This source code was highlighted with Source Code Highlighter.

No comments:

Post a Comment