By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,986 Members | 1,193 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,986 IT Pros & Developers. It's quick & easy.

C# objects

P: n/a
Hi,
In many other programming languages is construction with.
with <object_name> do
begin
....
end.

Is there something similar in c#?

May 12 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
>Is there something similar in c#?

No, C# doesn't have a with statement.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
May 12 '06 #2

P: n/a
"Jazer" <jo*************@gmail.com> wrote in message
news:Ow**************@TK2MSFTNGP02.phx.gbl...
Is there something similar in c#?


Thankfully, no...
http://www.google.com/search?hl=en&l...h+statement%22
May 12 '06 #3

P: n/a
In C# you can use the using keyword as follows
MyObject object = new MyObject();
using (object)
{
...
}

or.....

using (MyObject object = new MyObject())
{
...
}
"Jazer" <jo*************@gmail.com> wrote in message news:Ow**************@TK2MSFTNGP02.phx.gbl...
Hi,
In many other programming languages is construction with.
with <object_name> do
begin
...
end.

Is there something similar in c#?


May 12 '06 #4

P: n/a
That is nothing like the "with" statement. It is simply a mechanism for
ensuring that an instance is disposed.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Neil Stevens" <ne**********@traveltrust.co.uk> wrote in message
news:un**************@TK2MSFTNGP04.phx.gbl...
In C# you can use the using keyword as follows
MyObject object = new MyObject();
using (object)
{
...
}

or.....

using (MyObject object = new MyObject())
{
...
}
"Jazer" <jo*************@gmail.com> wrote in message
news:Ow**************@TK2MSFTNGP02.phx.gbl...
Hi,
In many other programming languages is construction with.
with <object_name> do
begin
...
end.

Is there something similar in c#?

May 12 '06 #5

P: n/a


Kevin Spencer wrote:
That is nothing like the "with" statement. It is simply a mechanism for
ensuring that an instance is disposed.

and why they picked 'using' beats me.
May 12 '06 #6

P: n/a
Ian Semmel <is***********@NOKUNKrocketcomp.com.au> wrote:
Kevin Spencer wrote:
That is nothing like the "with" statement. It is simply a mechanism for
ensuring that an instance is disposed.

and why they picked 'using' beats me.


At least it avoids introducing a new keyword.

-- Barry
May 12 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.