Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Is there a with-end with code in C# as there is in VB .Net?

It's a pain to type the same object name over and over again. Any way around this?

1 Answer

Relevance
  • Pfo
    Lv 7
    1 decade ago
    Favorite Answer

    C# does not have the "with, end with" syntax that VB.Net offers.

    It does have some nice syntactic options though. If you're just initializing properties, you can do this:

    MyObject o = new MyObject()

    {

    Property1 = "This";

    Property2 = 4;

    }

Still have questions? Get your answers by asking now.