# Getting the name of a delegate

**URL:** <https://forum.xojo.com/t/getting-the-name-of-a-delegate/44650>\
**Category:** General\
**Created:** [August 4, 2018, 11:41pm UTC](https://forum.xojo.com/t/getting-the-name-of-a-delegate/44650 "2018-08-04T23:41:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Bombay](https://forum.xojo.com/user_avatar/forum.xojo.com/alex_bombay/32/224_2.png) [@Alex\_Bombay](https://forum.xojo.com/u/Alex_Bombay)\
**Post date:** [August 4, 2018, 11:41pm UTC](https://forum.xojo.com/t/getting-the-name-of-a-delegate/44650/1 "2018-08-04T23:41:12Z")

</div>

Good day everyone!

I have a class with a property that gets set to a delegate method, I would like to get the name of this method in the form of a string/text.

In the debugger, I am able to find the name under “Delegate Members” by clicking on the delegate method property and then clicking on “Contents”.

Does anyone know a way to programmatically get this string?

Thanks!

---

<div class="post-metadata">

**Author:** ![Mike\_D](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_d/32/266_2.png) [@Mike\_D](https://forum.xojo.com/u/Mike_D)\
**Post date:** [August 4, 2018, 11:49pm UTC](https://forum.xojo.com/t/getting-the-name-of-a-delegate/44650/2 "2018-08-04T23:49:49Z")

</div>

In general, this is the kind of think you can do with [https://documentation.xojo.com/index.php/Introspection](https://documentation.xojo.com/index.php/Introspection)

Whether Introspection can get the name of a Delgate, I’m not sure. What have you tried?

---

<div class="post-metadata">

**Author:** ![Alex\_Bombay](https://forum.xojo.com/user_avatar/forum.xojo.com/alex_bombay/32/224_2.png) [@Alex\_Bombay](https://forum.xojo.com/u/Alex_Bombay)\
**Post date:** [August 4, 2018, 11:56pm UTC](https://forum.xojo.com/t/getting-the-name-of-a-delegate/44650/3 "2018-08-04T23:56:34Z")

</div>

[quote=399305:@Michael Diehr]In general, this is the kind of think you can do with [https://documentation.xojo.com/index.php/Introspection](https://documentation.xojo.com/index.php/Introspection)

Whether Introspection can get the name of a Delgate, I’m not sure. What have you tried?[/quote]

I tried to use introspection, both MethodInfo and PropertyInfo. I wasn’t able to make any headway on it.

---

<div class="post-metadata">

**Author:** ![Mike\_D](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_d/32/266_2.png) [@Mike\_D](https://forum.xojo.com/u/Mike_D)\
**Post date:** [August 5, 2018, 12:03am UTC](https://forum.xojo.com/t/getting-the-name-of-a-delegate/44650/4 "2018-08-05T00:03:14Z")

</div>

Yeah, I just tried a simple test, and it doesn’t work:

```auto
Delegate Foo(x as integer, y as integer)
Method Bar(x as integer, y as integer)

App.Open
   DoDelgate (addressOf Bar)

Sub DoDelegate(f as Foo)
  dim t as Introspection.TypeInfo = Introspection.GetType(d)
  dim a() as Introspection.AttributeInfo = t.GetAttributes
  dim c() as Introspection.ConstructorInfo = t.GetConstructors
  dim m() as Introspection.MethodInfo = t.GetMethods  
  dim p() as Introspection.PropertyInfo = t.GetProperties
  break
  MsgBox t.FullName
```

displays “Delegate”

---

<div class="post-metadata">

**Author:** ![Alex\_Bombay](https://forum.xojo.com/user_avatar/forum.xojo.com/alex_bombay/32/224_2.png) [@Alex\_Bombay](https://forum.xojo.com/u/Alex_Bombay)\
**Post date:** [August 5, 2018, 2:17am UTC](https://forum.xojo.com/t/getting-the-name-of-a-delegate/44650/5 "2018-08-05T02:17:32Z")

</div>

[quote=399308:@Michael Diehr]Yeah, I just tried a simple test, and it doesn’t work:

```auto
Delegate Foo(x as integer, y as integer)
Method Bar(x as integer, y as integer)

App.Open
   DoDelgate (addressOf Bar)

Sub DoDelegate(f as Foo)
  dim t as Introspection.TypeInfo = Introspection.GetType(d)
  dim a() as Introspection.AttributeInfo = t.GetAttributes
  dim c() as Introspection.ConstructorInfo = t.GetConstructors
  dim m() as Introspection.MethodInfo = t.GetMethods  
  dim p() as Introspection.PropertyInfo = t.GetProperties
  break
  MsgBox t.FullName
```

displays “Delegate”[/quote]

Yes, I got the same result.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 7:18pm UTC](https://forum.xojo.com/t/getting-the-name-of-a-delegate/44650/6 "2020-10-29T19:18:35Z")

</div>


