Reflection in D

medhi558 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jan 28 00:18:15 PST 2017


On Saturday, 28 January 2017 at 07:39:51 UTC, rumbu wrote:
> On Saturday, 28 January 2017 at 07:10:27 UTC, medhi558 wrote:
>> I have a last question, currently i use :
>> if(lc.name.indexOf("protocol.messages") != -1)
>>
>> To know if the class is a NetworkMessage, Would be possible to 
>> do this
>>
>> if(lc is NetworkMessage)
>>
>>
>> Sorry for my English, i speak french.
>
> if (auto nm = cast(NetworkMessage)lc)
> {
>   //do something with nm
> }

It doesn't work because lc is TypeInfo_Class


More information about the Digitalmars-d-learn mailing list