Get Current NameSpace

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I have a general routine in a windows app to get an embedded resource using
GetManifestResourceStream, Is it possible for when I call my routine to use
some kind of reflection to get the current namespace from where it was
called as I'm not a big fan of Hardcoding these things. ie

myBMP = MyGetResourceFunc(SomeReflectionMethod() +
".ImageFolder.Hi.bmp")

instead of...
myBMP =
MyGetResourceFunc("MyCompany.MyApp.MyComponent.ImageFolder.Hi.bmp")

I know its not very important but thought it may be possible.
Thanks in advance.
 
You can use the GetType() method inherited from object
class. This will give you the type of the current instance

You can also use Assembly.GetExecutingAssembly().FullName


namespace Garden.Flowers
{
public class Rose()
{
//will output Garden.Flower.Rose
Console.WriteLine(GetType().ToString());
}
}
 
many thanks tribal.

tribal said:
You can use the GetType() method inherited from object
class. This will give you the type of the current instance

You can also use Assembly.GetExecutingAssembly().FullName


namespace Garden.Flowers
{
public class Rose()
{
//will output Garden.Flower.Rose
Console.WriteLine(GetType().ToString());
}
}
 
Back
Top