Tangible Software Solutions

The Most Trusted Name in Source Code Conversion

  • Trusted for over 12 Years
  • Saves Valuable Time
  • Accurate and Reliable
  • Responsive Support

C# Equivalent to VB With

With is considered by some to be poor programming practice because it obscures the contained code purely for the benefit of reduced typing of one object name during development (you can't see what object you're applying the With operator to from within in the middle of a long With block).

If you want to simulate With in C#, then you can use abbreviated variable names, but this also obscures your code (but it can be applied to more than one object at the same time, while With can't).

Another alternative is to refactor so that the With block is a new method with the object passed in as a parameter.  You can use a reduced parameter name length (without making it obscure).

If you need to convert between VB and C# and you are depending on the results being reliable and accurate, then you will want to have Instant C#, the best VB to C# converter, or Instant VB, the best C# to VB converter, at your fingertips.

Copyright © 1997 - 2017 Tangible Software Solutions Inc.