如何在static属性获得本类型的FullName

真相重于对错 2004-10-18 08:22:27

在普通属性里可以通过this获得type,进而获得FullName
例如:
public class1
{
...
public int IM{
get{
Type type = this.GetType();
string str = type.FullName;
......
}
set{}
}
}
如果是一个static方法如何获得
...全文
123 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
jiezhi 2004-10-18
  • 打赏
  • 举报
回复
对static的方法多态?
建议你不要使用static的
真相重于对错 2004-10-18
  • 打赏
  • 举报
回复
因为static类型无法设为virtual
但我想对static使用多态
也就是在基类里加一个静态属性在其中
获得它的类型名
让子类中自动获得子类的类型名。并根据用户配置文件获得各个类的配置
jimh 2004-10-18
  • 打赏
  • 举报
回复
不错
TAIOU4 2004-10-18
  • 打赏
  • 举报
回复
我用 TypeName() 的
ControlType = TypeName(Object) 便行
真相重于对错 2004-10-18
  • 打赏
  • 举报
回复
MethodInfo mi=typeof(yourClass //就是不想用直接传入类型
).GetMethod(声明的静态方法名);
jiezhi 2004-10-18
  • 打赏
  • 举报
回复
思归的方法可行
tongcheng 2004-10-18
  • 打赏
  • 举报
回复
看看
up一下
daou101 2004-10-18
  • 打赏
  • 举报
回复
try:

MethodInfo mi=typeof(yourClass).GetMethod(声明的静态方法名);

使用mi也可以得到吧。
zhpsam109 2004-10-18
  • 打赏
  • 举报
回复
顶!向思归学习!
wangxt 2004-10-18
  • 打赏
  • 举报
回复
你用MemberInfo.DeclaringType试试行不行
zhouye6666 2004-10-18
  • 打赏
  • 举报
回复

saucer(思归)
传说中的五星级大哥出现了。
saucer 2004-10-18
  • 打赏
  • 举报
回复
try


Type t = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
jiezhi 2004-10-18
  • 打赏
  • 举报
回复
你可以利用反射在此类之外的类中的方法得到其fullname
fxyfx 2004-10-18
  • 打赏
  • 举报
回复
ding

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧