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 8366121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:50:05+00:00 2026-06-09T12:50:05+00:00

Possible Duplicate: Why C# is not allowing non-member functions like C++ Instead of writing

  • 0

Possible Duplicate:
Why C# is not allowing non-member functions like C++

Instead of writing StaticClass.Function() I’d like to simply write Function(). There will be many functions and all should be accessible from different (and unrelated) classes and files. How do I put these functions in a specific namespace? Simply declaring it there will give me a compile error

error CS1518: Expected class, delegate, enum, interface, or struct

I know other .NET languages can do it. Is there a compile option i may use? Perhaps even undocumented?

  • 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-09T12:50:07+00:00Added an answer on June 9, 2026 at 12:50 pm

    C# does not allow for free functons. Each function must reside in a type. This is just the way it works, it’s not a matter of technical possibility, it was a design decision.

    You may be interested in this article.


    On a side note, ever notice how Intellisense works much, much better when writing C# than C++? This is one of those things that help (not the only one, but one).

    EDIT: Funny, in reading that linked article I noticed that this is a dup…

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

Sidebar

Related Questions

Possible Duplicate: iOS - Detecting whether or not device support phone calls? I'm writing
Possible Duplicate: When does invoking a member function on a null instance result in
Possible Duplicate: Why is there not a ForEach extension method on the IEnumerable interface?
Possible Duplicate: getline not asking for input? There is some unique thing happening in
Possible Duplicate: Data not writing out to Database I'm trying to update a bit
Possible Duplicate: Why does C# not provide the C++ style ‘friend’ keyword? I'd like
Possible Duplicate: Why not use Double or Float to represent currency? I'm writing a
Possible Duplicate: Error: could not find function … in R Question: why do my
Possible Duplicate: Error: could not find function … in R I am trying to
Possible Duplicate: Not possible to launch a file on a network using Java Desktop?

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.