本文介绍了有没有一种方法来“别名”一个类属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在VB.Net 2010中编写一个泛型类,用于多个程序,并希望该类使用通用属性名称,以便我可以简单地在文件之间复制类并保持相同。我遇到的问题是,如果每个不同的实例化程序能够''别名''属性名称,以便intellisense将使用别名但是我不必重写所有属性名称,那将会更有用。类。诸如 Class BitFlags 公共 属性 flag0 作为 布尔 获取 返回 GetBit( 0 ) 结束 获取 设置( ByVal 值 As 布尔) 如果值= True 然后 SetBit( 0 ) 如果值= False 然后 ResetBit( 0 ) 结束 设置 结束 属性 结束 类 以及实例化程序可以做这样的事情 dim myflags = new BitFlags ' 一些别名函数 别名 myAlias = myflags.flag0 myAlias = True myAlias = 错误 谢谢!解决方案 I am writing a generic class in VB.Net 2010 to use in multiple programs and would like the class to utilize generic property names so that I can simply copy the class between files and keep it the same. The problem I have is that it would be much more useful if each different instantiating program were able to ''alias'' the property names such that intellisense would use the alias but I wouldn''t have to rewrite all the properties names in the class. Something such asClass BitFlags Public Property flag0 As Boolean Get Return GetBit(0) End Get Set(ByVal Value As Boolean) If Value = True Then SetBit(0) If Value = False Then ResetBit(0) End Set End PropertyEnd Classand where the instantiating program could do something like thisdim myflags = new BitFlags'some alias functionAlias myAlias = myflags.flag0myAlias = TruemyAlias = FalseThank you! 解决方案 这篇关于有没有一种方法来“别名”一个类属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-27 13:46