简体   繁体   中英

How can I find the namespace for a C# class?

Totally new to C# but have to write some code. eg In this sample, https://github.com/restsharp/RestSharp/wiki/Getting-Started , HttpBasicAuthenticator class is not found, I need to add a using "namespace", but don't know which namespace this class belong to. Is there a place I can search?

Premise: you can find class namespace above its declaration.

If you want to add reference of ax namespace from your class and you work on Visual Studio, just point the cursor on class name (ie "HttpBasicAuthenticator") and hit "CTRL + ."

A menu should open in which you can add the reference to HttpBasicAuthenticator class.

PS If you still can't see a reference to a already existence class, try adding the right reference from your project

In this case is really easy since you have the repository for the class. So you could search the class name in github the find the code file associated with that class and get the name space from there.

在此处输入图片说明

Update based on your comment

For general cases you have to be sure you have a reference to a dll containing that class. Then you could right click on the dll and select View in Object Browser .

在此处输入图片说明

Then in the popup window you will be able to search by the class name.

在此处输入图片说明

If the class name exists you will see the container namespace in bottom right panel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM