c# - pass ENUM(CustomType) to Another Class, where that ENUM doesn't exist -
//question update
let's say, new project, create file, have:
namespace a{ public enum mydates{ 19a, 19b, 19c, ..... } .... public class myabc : transaction{ .... string smth = myfunc(mydates.19a); .... } }
i have custom library-file (let's same, or different namespace), include in every projects , fill new methods according needs. now, want add method there, can called whenever need pass mydates
type:
namespace a{ partial class transaction{ ...... public string myfunc(mydates smth){ return (smth == mydates.19a ? 'hi' : (smth == mydates.19b ? ( etc... ) ) ) ; } ...... } }
however, namespace b
won't compile (because mydates
doesnt exist there). never call method without enum, , why still requires me define enum within namespace again? mydates
dynamic , can changed (removed values), , don't want modify library every time.
mydates dynamic , can changed (removed values) , dont want modify library everytime.
the way achieve enum
consuming code only access enum
via reflection (enum.getnames()
/ enum.getvalues()
), , not rely on values existed @ compile-time. can done, suggests maybe enum
not best choice data, if removing items. removing members inherently change can break consumers.
Comments
Post a Comment