PC Review


Reply
Thread Tools Rate Thread

C# and VB.Net keyword

 
 
=?Utf-8?B?Sm/Dq2w=?=
Guest
Posts: n/a
 
      9th May 2005
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

 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      9th May 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.
 
Reply With Quote
 
=?Utf-8?B?RGF2aWQgQW50b24=?=
Guest
Posts: n/a
 
      9th May 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
>

 
Reply With Quote
 
=?Utf-8?B?Sm/Dq2w=?=
Guest
Posts: n/a
 
      10th May 2005
Thanks all for your responses.
But it's strange MS forgot to put this option in C#...

Joël

 
Reply With Quote
 
Mattias Sjögren
Guest
Posts: n/a
 
      10th May 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/arch...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.
 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      10th May 2005
Jo?l <(E-Mail Removed)> 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 - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
=?Utf-8?B?Sm/Dq2w=?=
Guest
Posts: n/a
 
      10th May 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/arch...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.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I remove lines of data above a keyword and below a keyword in a text file Quentin Microsoft VB .NET 1 25th Apr 2007 04:15 PM
How do I remove lines of data above a keyword and below a keyword in a text file Quentin Microsoft VB .NET 0 25th Apr 2007 02:25 PM
Can we use join keyword without using INNER keyword explicitly in. =?Utf-8?B?Uy5TUklLQU5USCxHVURJV0FEQSxBUCxJTkRJQQ== Microsoft Access Queries 1 20th Apr 2005 02:07 PM
Difference between C#'s "new" keyword and VB.NET's "shadows" keyword Dot net work Microsoft C# .NET 8 29th Aug 2004 11:00 AM
Provider keyword in connection string not a valid keyword J. Muenchbourg Microsoft Dot NET 1 18th Mar 2004 09:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:22 AM.