How can I retrieve the namespace to a string C# -


i writing program needs namespace of program cant seem figure out how retrieve it. end result in string.

i able find msdn page topic proved unhelpful myself. http://msdn.microsoft.com/en-us/library/system.type.namespace.aspx

any appreciated. program written in c#.

edit: sorry guys, not console application.

this should work:

var mytype = typeof(myclass); var n = mytype.namespace; 

write out console:

type mytype = typeof(myclass); console.writeline("namespace: {0}.", mytype.namespace); 

setting winform label:

type mytype = typeof(myclass); namespacelabel.text = mytype.namespace; 

or create method in relevant class , use anywhere:

public string getthisnamespace() {    return gettype().namespace; } 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -