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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:15:13+00:00 2026-06-16T04:15:13+00:00

I have been using javascript and I made a lot of use of functions

  • 0

I have been using javascript and I made a lot of use of functions inside of functions. I tried this in C# but it seems they don’t exist. If I have the following:

public abc() {


}

How can I code a method d() that can only be called
from inside the method the method abc() ?

  • 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-16T04:15:14+00:00Added an answer on June 16, 2026 at 4:15 am

    I wouldn’t worry so much about the restriction of access to a method on the method level but more class level, you can use private to restrict access of the method to that specific class.

    Another alternative would be to use lambdas/anonymous methods, or if you’re using C# 4.0, Action/Tasks to create them inside your method.

    An example of an anonymous method using a delegate (C# 1/2/3/4) for your specific example (incl. I need an action that can take a string parameter and return a string?) would be something like this:

    delegate string MyDelegate(string);
    
    public void abc() {
        // Your code..
    
        MyDelegate d = delegate(string a) { return a + "whatever"; };
        var str = d("hello");
    }
    

    .. using C# 3/4:

    public void abc() {
        // Your code..
    
        Func<string, string> d = (a) => { return a + "whatever"; };
        var str = d("hello");
    }
    

    .. using a more ideal solution through private method:

    private string d(string a)
    {
        return a + "whatever";
    }
    
    public void abc()
    {
        // Your code..
    
        var str = d("hello");
    }
    

    Based on your comment for another answer: I would just like to have this at the bottom of the method and then call it from some earlier code.

    This won’t be possible, you would need to define a variable for your method using either delegates or Actions and so it would need to be fully initialised by time you call it. You wouldn’t then be able to define this at the bottom of your method. A much better option would be to simply create a new private method on your class and call that.

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

Sidebar

Related Questions

I have been using JavaScript as a tool for many years now, but only
We have been using javascript hashes a lot lately, and we've been looking for
I have been using some Javascript to create a text field once an certain
I have been using the Facebook Javascript SDK to post content from a CMS
Hi I have been trying to learn Javascript using codeacademy.com and I have reached
I've been using Firebug to debug some javascript I have on one of my
I have been trying to make custom radio buttons using HTML, CSS, and JavaScript.
I have built a Facebook app using the Javascript SDK that has been up
I have been using javascript for some while now and recently began using jquery
I have made an AJAX chat using Javascript, PHP, and MySQL. I send the

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.