473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Resolving current namespace

Hi,

Is there a way to resolve the current namespace in a static method, such as
Main() from within a console app?

In a public method from a class instance, you can use the "this" keyword in
(this.GetType().Namespace) to resolve the namespace, but you can't do that
from within a static method.

Any ideas?
Nov 16 '05 #1
2 2116
> Is there a way to resolve the current namespace in a static method, such
as
Main() from within a console app?

Since you're doing this from withing the class you know the class name and
therefore you can use typeof.

namespace MyNamespace {
public class MyClass
{
public static void Main()
{
Console.Write(typeof(MyClass).Namespace);
}
}
}

This will work with dynamic methods as well.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
Nov 16 '05 #2
That did the trick. Thanks!

- Glen

"Anders Norås [MCAD]" <an**********@objectware.no> wrote in message
news:uo**************@TK2MSFTNGP11.phx.gbl...
Is there a way to resolve the current namespace in a static method, such
as
Main() from within a console app?

Since you're doing this from withing the class you know the class name and
therefore you can use typeof.

namespace MyNamespace {
public class MyClass
{
public static void Main()
{
Console.Write(typeof(MyClass).Namespace);
}
}
}

This will work with dynamic methods as well.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lee Chapman | last post by:
Has anyone successfully been able to use an XmlValidatingReader (Framework 1.1) to validate documents against XML Schemas that haven't been added to the XmlValidatingReader.Schemas collection...
13
by: placid | last post by:
Hi all, I was just if anyone knows a way to resolve a list of integers say {1,2,3,4,5} into a range that is 1-5? #include <stdlib.h> #include <stdio.h> #include <ctype.h> int main(int...
6
by: placid | last post by:
Thanks everyone i got it to work at last but how would we resolve numbers inside a integer linked-list and ive been writing out flow-chart for this problem but i cant seem to be getting my head...
2
by: Kyle Blaney | last post by:
Suppose I have the following in file1.cs (all code is compacted to reduce the number of lines): namespace B { namespace C { class D { public static void Print() { System.Console.WriteLine(...
1
by: Islam Elkhayat | last post by:
How can i get my current Namespace & current class in my webform... I tried alot but i get ASP.myformname_aspx... Is there a way to get Current Namespace, class??
1
by: PJ6 | last post by:
The Page class has a nice little function called ResolveURL. Can I get to something like that in global.asax, ar at least the originating page within any particular event? Paul
1
by: Mike Walters | last post by:
Reading the current Namespace.Class, Assemble at runtime I am trying to get the Assemble, Namespace and Class name of a form at runtime. I have several assembles and namespaces in my app, I...
3
by: namewitheldbyrequest | last post by:
"The XML element 'EnableTheming' from namespace 'http://tempuri.org/' is already present in the current scope" I created a Web Service: I imported System.Data.SqlClient so I could access SQL...
4
by: iwdu15 | last post by:
Hi, in VB i could use the keyword Now to get the current DateTime, but C# doesnt have that. How can i get the current time? thanks -- -iwdu15
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.