\u7136\u540e\u518d\u6765\u770b\u770b\u901a\u8fc7 \u53cd\u5c04 \u6765\u83b7\u53d6 Customer \u4e0b\u6240\u6709\u5b9a\u4e49\u7684\u6784\u9020\u51fd\u6570\uff0c\u4e0d\u8fc7\u8fd9\u91cc\u53ea\u5b9a\u4e49\u4e86\u4e00\u4e2a\u6784\u9020\u51fd\u6570\uff0c\u56e0\u6b64\u53ea\u80fd\u5217\u51fa\u4e00\u4e2a\u3002<\/p>\n
class Program \r\n { \r\n static void Main(string[] args) \r\n { \r\n Type type = typeof(Customer); \r\n \r\n ConstructorInfo[] constructorInfo = type.GetConstructors(); \r\n \r\n Console.WriteLine(\"The Customer class contains the following Constructors:--\"); \r\n \r\n foreach (ConstructorInfo c in constructorInfo) \r\n { \r\n Console.WriteLine(c); \r\n } \r\n } \r\n } \r\n<\/pre>\n
\n\u540c\u6837\u4e5f\u8981\u6ce8\u610f\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b GetConstructors() \u65b9\u6cd5\u53ea\u80fd\u83b7\u53d6 Customer \u7684\u6240\u6709\u6807\u8bb0\u4e3a public \u7684\u6784\u9020\u51fd\u6570\u3002<\/p>\n
\u63a5\u4e0b\u6765\u770b\u770b\u5982\u4f55\u5c55\u793a Customer \u4e2d\u7684\u6240\u6709 public \u65b9\u6cd5\uff0c\u56e0\u4e3a\u8be5\u7c7b\u4e2d\u53ea\u5b9a\u4e49\u4e86\u4e00\u4e2a public \u65b9\u6cd5\uff0c\u6240\u4ee5\u63a7\u5236\u53f0\u4e0a\u4e5f\u5e94\u8be5\u53ea\u4f1a\u5c55\u793a\u4e00\u4e2a\uff0c\u5982\u4e0b\u4ee3\u7801\u4ec5\u4f9b\u53c2\u8003\u3002<\/p>\n
static void Main(string[] args) \r\n { \r\n Type type = typeof(Customer); \r\n \r\n MethodInfo[] methodInfo = type.GetMethods(); \r\n \r\n Console.WriteLine(\"The methods of the Customer class are:--\"); \r\n \r\n foreach (MethodInfo temp in methodInfo) \r\n { \r\n Console.WriteLine(temp.Name); \r\n } \r\n \r\n Console.Read(); \r\n } \r\n<\/pre>\n
\n\u662f\u4e0d\u662f\u5f88\u60ca\u8bb6\uff0c\u521a\u624d\u8fd8\u8bf4\u662f\u4e00\u4e2a\u65b9\u6cd5\uff0c\u5c45\u7136\u591a\u4e86\u597d\u51e0\u4e2a\uff0c\u8981\u77e5\u9053\u591a\u7684\u90a3\u51e0\u4e2a\u65b9\u6cd5\uff0c\u6765\u81ea\u4e8e\u4e24\u65b9\u9762\u3002<\/p>\n
\u4ece object \u7c7b\u578b\u7ee7\u627f\u4e0b\u6765\u7684\u516c\u5171\u65b9\u6cd5
\n<\/p>\n
\u7f16\u8bd1\u5668\u81ea\u52a8\u751f\u6210\u7684\u5c5e\u6027\u65b9\u6cd5
\n<\/p>\n
\u5982\u679c\u65b9\u6cd5\u4e0a\u9762\u6807\u8bb0\u4e86 Attribute, \u8fd8\u53ef\u4ee5\u901a\u8fc7 GetCustomAttributes \u65b9\u6cd5\u6765\u83b7\u53d6\uff0c\u53c2\u8003\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n
static void Main(string[] args) \r\n { \r\n foreach (MethodInfo temp in methodInfo) \r\n { \r\n foreach (Attribute attribute in temp.GetCustomAttributes(true)) \r\n { \r\n \/\/Write your usual code here \r\n } \r\n } \r\n } \r\n<\/pre>\n\u76f8\u4fe1\u5728\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u7ecf\u5e38\u4f1a\u5728 \u9886\u57df\u5b9e\u4f53 \u4e0a\u4f7f\u7528\u5404\u79cd Attribute \u7279\u6027\uff0c\u8fd9\u65f6\u5019\u5c31\u53ef\u4ee5\u901a\u8fc7\u4e0a\u9762\u7684\u4ee3\u7801\u53cd\u5c04\u63d0\u53d6 \u9886\u57df\u5b9e\u4f53 \u4e2d\u7684\u65b9\u6cd5\u4e0a\u7684Attribute\u4fe1\u606f\uff0c\u4ece\u800c\u6839\u636e\u63d0\u53d6\u5230\u7684 Attribute \u6267\u884c\u4f60\u7684\u5177\u4f53\u4e1a\u52a1\u903b\u8f91\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
C# \u4e2d\u7684 \u53cd\u5c04 \u5e38\u7528\u4e8e\u5728\u7a0b\u5e8f\u7684\u8fd0\u884c\u65f6\u83b7\u53d6 \u7c7b\u578b \u7684\u5143\u6570\u636e\uff0c\u53ef\u83b7\u53d6\u7684\u4fe1\u606f\u5305\u62ec\u5df2\u52a0\u8f7d\u5230\u8fdb\u7a0b\u4e2d\u7684 \u7a0b\u5e8f\u96c6 \u548c \u7c7b\u578b […]<\/p>\n","protected":false},"author":1898,"featured_media":210737,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[633],"class_list":["post-208537","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread","tag-c--"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/208537","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1898"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=208537"}],"version-history":[{"count":6,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/208537\/revisions"}],"predecessor-version":[{"id":210738,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/208537\/revisions\/210738"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/210737"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=208537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=208537"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=208537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}