Best practice regarding returning from using blocks
Posted
by abatishchev
on Stack Overflow
See other posts from Stack Overflow
or by abatishchev
Published on 2009-08-03T18:24:32Z
Indexed on
2010/04/04
15:53 UTC
Read the original article
Hit count: 325
Which way is better practice: return a value from a method inside an using
statement or declare a variable before, set it inside and return it after?
public int Foo()
{
using(..)
{
return bar;
}
}
or
public int Foo()
{
var b = null;
using(..)
{
b = bar;
}
return b;
}
© Stack Overflow or respective owner