-
Oct 19th, 2021, 01:22 PM
#1
Thread Starter
New Member
What is the equivalent of static from VB.Net in C#
Please help me to know equivalent of static from VB.Net in C#
Thanks
Jayachandra
-
Oct 19th, 2021, 02:14 PM
#2
Re: What is the equivalent of static from VB.Net in C#
Usually it is shared. E.g.:
Code:
public class Foo
{
public static string Bar()
{
return "bar";
}
}
Fiddle: https://dotnetfiddle.net/Bo7TJw
Translates to:
Code:
Public Class Foo
Public Shared Function Bar() As String
Return "bar"
End Function
End Class
Fiddle: https://dotnetfiddle.net/y29zoq
-
Oct 19th, 2021, 02:56 PM
#3
Re: What is the equivalent of static from VB.Net in C#
It's not clear which way you're converting from your question, but if you mean what is the equivalent of VB 'Static' local variables in C#, then there is no equivalent - you have to declare fields (static C# fields for 'Static' locals within Shared methods, and non-static C# fields for 'Static' locals within non-Shared method).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|