Saturday, 17 August 2013

Assgin shared member to a const

Assgin shared member to a const

Supouse you have a class with shared members to make a reference to known
values like this
public class Semaphore()
{
public static int Red = 0;
public static int Yellow = 1;
public static int Green = 2;
}
In VB.Net you can assing these static(shared) values to a const like this:
Public Class Transit
Private Const Red as Integer = Semaphore.Red
End Class
But in C# this isn't possible. There is a reason for this? Some workaround?

No comments:

Post a Comment