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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:48:39+00:00 2026-05-28T22:48:39+00:00

I know this is a stupid question, but I have been teaching myself c#,

  • 0

I know this is a stupid question, but I have been teaching myself c#, so im learning the lingo as I go.

My question is: Often when I write methods, I find my self declaring objects and variables at the top of the method when I need them to share the same scope. Do these types of objects/variables have a name? I know when declared outside a method they would be properties.

Example code of what I mean: My question is what to call the objects in the Question region.

public Label start_Ping(String target, string name, ref bool router)
        {

       #region [ Question ] 
        Label status_Label = new Label(); //Declare the label which will be dynamically      created 

        Ping ping = new System.Net.NetworkInformation.Ping(); //Declare the ping object 

        PingReply reply = null; //Declare the pingReply object      


        byte[] buffer = new byte[100]; //Set the byte size 
       #endregion 

        if (name == "router")
        {
            try
            {
                reply = ping.Send(target, 50, buffer);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            if (reply.Status == IPStatus.Success)
            {
                router = true;
            }
            else
            {
                router = false;
                return null;
            }
        }
try
{
...

Thanks in advance. I understand this may be quite simple =)

  • 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-28T22:48:40+00:00Added an answer on May 28, 2026 at 10:48 pm

    In your code, status_Label, ping, reply and buffer are known simply as local variables.

    That is, they’re local to the method you create them in (or whatever scope you declare them in).

    It doesn’t matter where in your method you declare them, by the way, as long as they’re within some scope.

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

Sidebar

Related Questions

I know this may be a stupid question to ask but I have really
Forgive me if this is a stupid question, I know there have been similar
This may be a stupid question to ask, but still I need to know
This may be an incredibly stupid question, but I have a web application that
This may seem like a stupid question, but I've been looking everywhere to fix
I know this maybe a stupid question but maybe I'm just confused with the
this is a really stupid question but I have a deadline and I'm very
I know this might be a very stupid question but I am new to
This is probably a stupid question but will ask anyway sine I have no
This is probably a stupid question, but I still have no answer. I would

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.