Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1080123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:58:36+00:00 2026-05-16T21:58:36+00:00

In the Java and Python world, you look at a source file and know

  • 0

In the Java and Python world, you look at a source file and know where all the imports come from (i.e. you know in which file the imported classes are defined). For example:

In Java:

import javafoo.Bar;

public class MyClass {
    private Bar myBar = new Bar();
}

You immediately see that the Bar-class is imported from javafoo. So, Bar is declared in /javafoo/Bar.java

In Python

import pythonbaz
from pythonfoo import Bar

my_bar = Bar()
my_other = pythonbaz.Other()

Here, it is clear that Bar comes from the pythonfoo package and Other is obviously from pythonbaz.

In C# (correct me if I’m wrong):

using foo
using baz
using anothernamespace
...

public class MyClass
{
    private Bar myBar = new Bar();
}

Two questions:
1) How do I know where the Bar-class is declared? Does it come from the namespace foo, or bar, or anothernamespace? (edit: without using Visual Studio)

2) In Java, the package names correspond to directory names (or, it is a very strong convention). Thus, when you see which package a class comes from, you know its directory in the file system.

In C#, there does not seem to be such a convention for namespaces, or am I missing something? So, how do I know which directory and file to look in (without Visual Studio)? (after figuring out which namespace the class came from).

Edit clarification: I am aware that Python and/or Java allow wildcard imports, but the ‘culture’ in those languages frowns upon them (at least in Python, in Java I’m not sure). Also, in Java IDEs usually help you create minimal imports (as Mchl. commented below)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:58:36+00:00Added an answer on May 16, 2026 at 9:58 pm

    1) Well, you can do the same thing in Java too:

    import java.util.*;
    import java.io.*;
    
    ...
    
    InputStream x = ...;
    

    Does InputStream come from java.util or java.io? Of course, you can choose not to use that feature.

    Now, in theory I realise this means when you’re looking with a text editor, you can’t tell where the types come from in C#… but in practice, I don’t find that to be a problem. How often are you actually looking at code and can’t use Visual Studio?

    2) You can use the same convention in .NET too, of course – and I do, although I don’t have empty directories going up the chain… so if I’m creating a project with a default namespace of X.Y, then X.Y.Foo would be in Foo.cs, and X.Y.Z.Bar would be in Z\Bar.cs

    That’s also what Visual Studio will do by default – if you create a subfolder, it will create new classes using a namespace based on the project default and the folder structure.

    Of course, you can also declare types in any old file – but mostly people will follow the normal convention of declaring a type with a corresponding filename. Before generics made delegate declarations rarer, I used to have a Delegates.cs file containing all the delegate declarations for a particular namespace (rather than having a bunch of single-declaration files) but these days that’s less of an issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would you know if something similar to Terracotta (in Java world) exists for Python
I am learning Python at the moment, and I come from a Java/C++ and
I'm trying to call a java program from python using command line. The code
I know Jython converts Python code into Java byte code, but are there any
I'm calling a java program from my python code in the following way: subprocess.check_output([java,
Using Python, I want to know whether Java is installed.
I haven't done much python - coming from a C/Java background - so excuse
I know that more-dynamic-than-Java languages, like Python and Ruby, often allow you to place
I'm about to port a smallish library from Java to Python and wanted some
I'd like to know which Java web application frameworks provides a hot reload capability,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.