Here's an example of something I use in a static method (should work in a static class too).
public static Type[] GetKnownTypes()
{
Type thisType = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
return thisType.Assembly.GetTypes().ToList<Type>().Where(t => t.IsSubclassOf(thisType)).ToArray();
}
> On Saturday, April 28, 2007 3:29 PM Zytan wrote:
> Since the call stack can be changed in release, as functions are
> inlined, how can you be certain to get the current class name of any
> method that cares to know? Even IF it is an inlined method?
>
> Seems impossible to do.
>
> Zytan
>> On Saturday, April 28, 2007 9:08 PM dale097 wrote:
>> How about this.GetType()?
>> --
>> Dale Preston
>> MCAD C#
>> MCSE, MCDBA
>>
>>
>> "Zytan" wrote:
>>> On Sunday, April 29, 2007 7:23 PM Zytan wrote:
>>> Ok, that returns the namespace, as well, but that should be good
>>> enough.
>>>
>>> Thanks,
>>>
>>> Zytan
>>>> On Sunday, April 29, 2007 7:36 PM Zytan wrote:
>>>> Oh, wait, I had already tried that, and it did not work because I need
>>>> it to work on static classes. There is no "this" for a static class.
>>>>
>>>> Any more ideas?
>>>>
>>>> Zytan
>>>>> On Sunday, April 29, 2007 8:48 PM Zytan wrote:
>>>>> this.Name
>>>>>
>>>>> Zytan
>>>>> Submitted via EggHeadCafe
>>>>> SQL Operations on a Text File with ADO.NET
>>>>> http://www.eggheadcafe.com/tutorials...th-adonet.aspx