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

  • Home
  • SEARCH
  • 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 8451931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:22:23+00:00 2026-06-10T11:22:23+00:00

To avoid repetitive definitions, I am trying to move internal function prototypes from the

  • 0

To avoid repetitive definitions, I am trying to move internal function prototypes from the class One into a C# using My.Class.One directive (like import My.Class.One in Java).

In Java, this would change this code:

public class One {
   public static void func1();
   public static void func2();
   public static int main(String[] args) { ... }
}

…into that code split into different files:

import My.Include;

public class One {
   public static int Main(String[] args) { ... }
}
------------------------->8--------------------------------    
package Include;

public class My {
   public static void func1();
   public static void func2();
   ...
}

After learning that Java 'packages' are named 'namespaces' in C# I came up with the following C# code which fails to compile (mcs One.cs My_include.cs -out:One.exe) with the error:

> “error CS0103: The name `func1′ does not exist in the current context”

using System;
using My.Include;

public class One {
   public static int Main(String[] args) { return funct1(); }
}
------------------------->8--------------------------------    
using System;

namespace My {
   namespace Include {
      public class functions {
      public static void func1();
      public static void func2();
      ...
      }
   }
}

I tried many different naming conventions but I still get the same error. Can you tell me what I do wrong?

  • 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-06-10T11:22:25+00:00Added an answer on June 10, 2026 at 11:22 am

    It looks like you want a partial class, so your main class file would look like:

    // File:  One.cs
    using System;
    
    public class One
    {
        static void Main()
        {
            // Your Main method here
        }
    }
    

    And you would have a second file which looks like:

    // File:  One.Externs.cs
    using System;
    
    public partial class One
    {
        extern static void func1();
        extern static void func2();
    }
    

    At compile-time, these two (or more) files are automatically combined to a single class by the compiler. This gives you the separation you appear to be looking for, but keeps the relevant definitions within the correct scopes.

    The using directive is only partially synonymous to java’s import directive – in C# using only provides a shortcut into a namespace whereas you’re used to referring to a class or partial class with import.

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

Sidebar

Related Questions

Because I want to avoid repetitive code, and I'm using a lot of text
To avoid the long class path issue in windows, i modified my build.xml like[1]
I am trying to avoid C6011 warning because an abort function is calling exit().
Also trying to avoid any use of plugins, (apart from jQuery of course, whether
Trying to avoid repetition here. I have an action in a base class controller
Is there a good convention-based way to avoid repetitive code like the following in
I have a function of an class in C# that compares one object to
How to avoid a pair of repetitive lines before and after invocations in sample
I'd like to avoid this scary messages when users install my application: I understand
I'd like to avoid doing any needless HTTP requests on my site to improve

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.