Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. equivalaent of the delphi WITH statement

equivalaent of the delphi WITH statement

Scheduled Pinned Locked Moved C#
csharpdelphiregexquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sephless
    wrote on last edited by
    #1

    Is there a c# equivalaent of the delphi WITH keyword? WITH allows you to set a scope for class variables in a function, so that the class need only be specified once then all variable names that match with variable names inside the class are deemed to be from the specified class. ie. public class car { public int wheels; public bool isSofttop; } public main { car Audi = new car; WITH Audi do { wheels = 4; isSofttop = false; } }

    W D D 3 Replies Last reply
    0
    • S sephless

      Is there a c# equivalaent of the delphi WITH keyword? WITH allows you to set a scope for class variables in a function, so that the class need only be specified once then all variable names that match with variable names inside the class are deemed to be from the specified class. ie. public class car { public int wheels; public bool isSofttop; } public main { car Audi = new car; WITH Audi do { wheels = 4; isSofttop = false; } }

      W Offline
      W Offline
      Wraith2
      wrote on last edited by
      #2

      No.

      1 Reply Last reply
      0
      • S sephless

        Is there a c# equivalaent of the delphi WITH keyword? WITH allows you to set a scope for class variables in a function, so that the class need only be specified once then all variable names that match with variable names inside the class are deemed to be from the specified class. ie. public class car { public int wheels; public bool isSofttop; } public main { car Audi = new car; WITH Audi do { wheels = 4; isSofttop = false; } }

        D Offline
        D Offline
        DavidNohejl
        wrote on last edited by
        #3

        AFAIK no, there isn't equivalent to with. If you want to be 100% sure, google for ECMA-334(C# spec.) After quick glace into spec. there seems to be nothing similar to with statement. Personally, I am happy about. However you can use using to deal with namespaces. (which are often way much longer names) David Never forget: "Stay kul and happy" (I.A.)
        David's thoughts / dnhsoftware.org / MyHTMLTidy

        1 Reply Last reply
        0
        • S sephless

          Is there a c# equivalaent of the delphi WITH keyword? WITH allows you to set a scope for class variables in a function, so that the class need only be specified once then all variable names that match with variable names inside the class are deemed to be from the specified class. ie. public class car { public int wheels; public bool isSofttop; } public main { car Audi = new car; WITH Audi do { wheels = 4; isSofttop = false; } }

          D Offline
          D Offline
          Dave Doknjas
          wrote on last edited by
          #4

          The closest you can get to that is to use a temporary abbreviated variable: public main { car Audi = new car; car a = Audi; a.wheels = 4; a.isSofttop = false; } David Anton Tangible Software Solutions www.tangiblesoftwaresolutions.com Home of the Instant C# VB.NET to C# Converter and the Instant VB C# to VB.NET Converter

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups