Re: How to access this static variable

Tech-Archive recommends: Speed Up your PC by fixing your registry



First, have you looked at localization capabilities offered by the.NET
framework ?

If you want to access those members through an instance variable, why making
them static ? (I'm not sure but I see nowhere that you would really declare
them static on purpose ?).
Another option is to make them static but to have a single class and provide
the language they should provide. Remember that being a static member you
can stuff whatever you want (ie. your labels could come from any data
structure filled with strings for each supported language).

Or drop the static keyword and have your classes inherits and overrides your
default language class (could be abstract or an interface to make sure you
provide the appropriate text for each class).

For now it llklks like the code would direct to choose a design while you
choosed anothe design for the declarations. You have to match both aspects
(and have a llok at localization features if not already done).

--
Patrice

"LamSoft" <[nospam]lamsoft@xxxxxxxxxxx> a écrit dans le message de news:
uefBMnUyHHA.4824@xxxxxxxxxxxxxxxxxxxxxxx
I am trying to make a language file and put all Static variables into each
different cs.
For example:


Class english : language{
public static string TEST = "test";
}

Class chinese : language {
public static string TEST = "´ú¸Õ";
}

Class language {}




and now i wanna access the TEST variable, but according to which language
is being selected ..

and I expected the following and something like that...

Language myLanguage = new english();
myLanguage.TEST // output will be "test"

Language myLanguage = new chinese();
myLanguage.TEST // output will be "´ú¸Õ"


Thank you very much.



"Patrice" <http://www.chez.com/scribe/> wrote in message
news:Ohwcf%23TyHHA.5484@xxxxxxxxxxxxxxxxxxxxxxx
You may want to explain what you are trying to do so that we can
understand why not using A.ABC is not something that fit your needs and
why accessing static members through an instance member would make sense.
It could raise alternate approach to the problem you are trying to
solve..

---
Patrice


"LamSoft" <[nospam]lamsoft@xxxxxxxxxxx> a écrit dans le message de news:
eFWxziTyHHA.1100@xxxxxxxxxxxxxxxxxxxxxxx
But there are not only 1 static variable in Class A, .... i don't wanna
make every function for each static variable





"Hans Kesting" <news.2.hansdk@xxxxxxxxxxxxxxx> wrote in message
news:c04e80a71b5bb8c9975e161250ae@xxxxxxxxxxxxxxxxxxxxx
Class B { public B() {} }

Class A : B {
public static string ABC = "myABC";
public A() {}
}
main Program:

B myObject = new A();

and now is it possible to access "ABC" through "myObject" without
modifying the source code in Class A and Class B.

Thanks



As it's a static variable (in type A), you can only access it through
the Type A:
A.ABC, not through an instance.

Type B doesn't know anything about things declared in derived types
(like A),
so your myObject (which is "just a B") doesn't know anything about that
ABC.

*if* B declares a (virtual) method:
public virtual string MyMethod() { return "nil"; }
and A overrides it:
public override string MyMethod() { return A.ABC; }
then your myObject can still access the contents of ABC, using this
MyMethod()

Hans Kesting










.



Relevant Pages

  • Re: Conscious antipattern behavior
    ... The alternative is to declare functions *inline* ... > - Letting a class grow until it has a zillion members. ... The C++ computer programming language introduced ... many subtle new features to C programmers. ...
    (comp.lang.cpp)
  • Re: Language
    ... surprising that such a new pronunciation would be generally adopted. ... other members got a charge out of novel pronunciations. ... but IMO this doesn't explain the high mutability of language as ... courtship behaviors having become too different). ...
    (talk.origins)
  • Re: implementing non local returns in C++
    ... abstraction. ... exposing an API size_t sizeof_foo, or by providing a creation API ... but that's working around the language, ... Hidden members are not visible to any code ...
    (comp.lang.scheme)
  • Re: changing access modifier of base method
    ... I'm not sure if this counts as a different meaning than your #1...I'm not even sure if it's even an actual meaning (I've found varying quality in the Java resources I've seen:)). ... It's possible that the number of different semantic meanings was much less, given the overlap between inheritance behaviors in different members. ... It would be a pain to write in such a language, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Conservative Family Group Protesting the CBS 9/11 Documentary
    ... members to protest against CBS's decision to air an updated version of ... language used by blues musicians in a PBS documentary was indecent. ... warnings in the broadcast, and Robert De Niro, who will again serve as ... viewers to the graphic language. ...
    (rec.sport.pro-wrestling)