Alias for static member in C#? -
i have static member:
namespace mylibrary { public static class myclass { public static string mymember; } } which want access this:
using mylibrary; namespace myapp { class program { static void main(string[] args) { mymember = "some value."; } } } how make mymember accessible (without myclass.) myapp adding using mylibrary?
c# doesn't allow create aliases of members, of types. way in c# create new property accessible scope:
class program { static string mymember { { return myclass.mymember; } set { myclass.mymember = value; } } static void main(string[] args) { mymember = "some value."; } } it's not alias, accomplishes syntax you're looking for.
of course, if you're accessing / modifying member on myclass, , not assigning it, can simplified bit:
class program { static list<string> mylist = myclass.mylist; static void main(string[] args) { mylist.add("some value."); } }
Comments
Post a Comment