[solved - ticket:101] const members: how to access them
Posted: Fri Dec 19, 2008 1:26 am
with such cobra
and such c#
compiler give
it seems const string member are seen as instance instead of const.
How can I access const string members from c# libraries?
use System.Net
class Test
def main is shared
print ConstHolder.Foo.bar
print ConstHolder.FooFoo.baz
print StaticConstHolder.Foo.bar
print StaticConstHolder.FooFoo.baz
and such c#
- Code: Select all
public class ConstHolder {
public static class Foo {
public const string Bar = "ConstHolder.Foo.Bar";
}
public class FooFoo{
public const string Baz = "ConstHolder.FooFoo.Baz";
}
}
public class StaticConstHolder{
public static class Foo {
public const string Bar = "StaticConstHolder.Foo.Bar";
}
public class FooFoo {
public const string Baz = "StaticConstHolder.FooFoo.Baz";
}
}
compiler give
- Code: Select all
error: Cannot access instance member "Foo" on type "ConstHolder". Make the member "shared" or create an instance of the type.
error: Cannot access instance member "FooFoo" on type "ConstHolder". Make the member "shared" or create an instance of the type.
error: Cannot access instance member "Foo" on type "StaticConstHolder". Make the member "shared" or create an instance of the type.
error: Cannot access instance member "FooFoo" on type "StaticConstHolder". Make the member "shared" or create an instance of the type.
it seems const string member are seen as instance instead of const.
How can I access const string members from c# libraries?