Latest news for natural viagra substitutes

Average Rating: 4.5 out of 5 based on 298 user reviews.

I've felt the pain of having the not being able to return a value before, and just chalked it up to a limitation of the language. I never considered trying to find a better way, and usually ended up with something like:

void DoSomething()
{
    XmlDocument xml = new XmlDocument();
    using(var reader = new StreamReader(@"c:\somexmlfile. xml"))
    {
        xml. Load(reader);
    }

    // do something useful with xml
}
or
void DoSomething2()
{
    XmlDocument xml = new XmlDocument();
    [natural viagra substitutes] using( var reader = new StreamReader( @"c:\somexmlfile. xml" ) )
    {
        xml. Natural viagra substitutes load( reader );
        // do something useful with xml
    }
}
neither of which particularly suited me. Because
  • First example: Declaring the variable outside the scope of the block feels weird
  • Second example: Performing whatever operation inside the using block, means the file (or other resource) doesn't get released until the operation has completed.
After Shawn mentioned something about this at his talk, I started thinking about it a little bit, and then I had a real need for it (again), and decided to come up with something better.   Turns out what I wanted was blatantly simple.
TResult UsingReturn<TDisposable,  TResult>(TDisposable toUse,  Func<TDisposable,  TResult> func)
    where TDisposable : IDisposable
{
    using (toUse)
    {
   natural viagra substitutes      return func(toUse);
    }
}
Now the above example turns into:
void DoSomething3()
{
    var xml = UsingReturn( new StreamReader( @"c:\cdf. xml" ),  reader =>
                {
                    var doc = new XmlDocument();
                    doc. Load( reader );
                    return doc;
                });
}
I'm not sure where this thing should live (e. g. some static utility class natural viagra substitutes, extension method on IDisposable), or even what it should be called.   Any ideas?


?? 2008-2016 Legit Express Chemist.