equivalaent of the delphi WITH statement
-
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; } }
-
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; } }
-
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; } }
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 towith
statement. Personally, I am happy about. However you can useusing
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 -
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; } }
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