Hi!

VB.Net has the "static" keyword who allow me to declare a local variable
static like in C.
Is there any equivalence with C# ?
Thanks for your help.

Joël

Re: C# and VB.Net keyword by Mattias

Mattias
Mon May 09 08:15:30 CDT 2005


>Is there any equivalence with C# ?

No, use a class level field variable instead.



Mattias

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

RE: C# and VB.Net keyword by DavidAnton

DavidAnton
Mon May 09 11:31:02 CDT 2005

Replace it with a class-level variable, but be aware that this new variable
will have to be declared 'static' (no relation to VB 'static') if the method
containing the original variable was a Shared ('static' in C#) method.

i.e., local static variables in static methods convert to class-level static
variables in C# and local static variables in non-static methods convert to
class-level non-static variables in C#.

David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter
and the Instant VB C# to VB.NET converter

"Joël" wrote:

> Hi!
>
> VB.Net has the "static" keyword who allow me to declare a local variable
> static like in C.
> Is there any equivalence with C# ?
> Thanks for your help.
>
> Joël
>

RE: C# and VB.Net keyword by Jol

Jol
Tue May 10 15:41:01 CDT 2005

Thanks all for your responses.
But it's strange MS forgot to put this option in C#...

Joël


Re: C# and VB.Net keyword by Mattias

Mattias
Tue May 10 15:50:57 CDT 2005


>But it's strange MS forgot to put this option in C#...

What makes you think they forgot it? There are reasons why it's not
supported.

http://blogs.msdn.com/csharpfaq/archive/2004/05/11/130248.aspx



Mattias

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

RE: C# and VB.Net keyword by Jon

Jon
Tue May 10 16:31:46 CDT 2005

Jo?l <Jol@discussions.microsoft.com> wrote:
> Thanks all for your responses.
> But it's strange MS forgot to put this option in C#...

"Forgot" implies that it wasn't a deliberate omission, which I believe
it was.

Objects encapsulate state, as do types. Methods don't logically have
state. If a method has enough state, you should be considering
encapsulating it separately.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Re: C# and VB.Net keyword by Jol

Jol
Tue May 10 16:38:06 CDT 2005

Really ? I never thought they forgot it. It's just provocation. ;-)
Unfortunatly, even after reading the FAQ, I continuing to think unbelievable
they have decided to not support it.

"Mattias Sjögren" wrote:

>
> >But it's strange MS forgot to put this option in C#...
>
> What makes you think they forgot it? There are reasons why it's not
> supported.
>
> http://blogs.msdn.com/csharpfaq/archive/2004/05/11/130248.aspx
>
>
>
> Mattias
>
> --
> Mattias Sjögren [MVP] mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.
>