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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:38:32+00:00 2026-05-29T19:38:32+00:00

I am new to C# and am working on classes and understanding them. My

  • 0

I am new to C# and am working on classes and understanding them. My problem is I am not understanding how to create a Get to retrieve the private variable _yourname and Set to set the private variable _yourname.

namespace WindowsFormsApplication1
{
    class InputClass
    {
        private string _yourName;
        public string _banner;
        public virtual void GetInfo();
        public InputClass(String _banner)
        {
            _banner = "Enter your name";
        }
    }
}

Maybe I am using the wrong function to GetInfo. But I am also wondering when I have the GetInfo if in the () I should write _yourname in it.

  • 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-29T19:38:33+00:00Added an answer on May 29, 2026 at 7:38 pm

    In C# there are properties, which have the function of public getter and setter methods in other languages:

        class InputClass
          {
            private string _yourName;
            public string _banner;
    
            public InputClass(String _banner)
            {
                this._banner = _banner;    
            }
    
            public string YourName 
            {
                 get { return _yourName; }
                 set { _yourName = value; }
            }
    
        }
    

    But you can use auto properties, if you want:

        class InputClass
        {
           public InputClass(String _banner)
            {
                Banner = _banner;    
            }
    
            public string YourName 
            {
                get; set;
            }
    
            public string Banner 
            {
                get; set;
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can get this working with an XmlDataSource but not with my own classes.
I'm very new to working with databases in C# (but not C# itself) and
I am working with the classes in the System.Windows.Documents namespace, trying to write some
I am new to C# and I am working on classes. What is the
I'm just learning C# and trying to get some practice working with classes as
i am new to android and i am working on understanding the concept of
I'm pretty new to python. This is my first time working with classes in
I have two classes (let's call them Working and ReturnStatement) which I can't modify,
Im new to working with Domain Models so forgive me for asking an elementary
I am new to working with C# and databases. I need to iterate over

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.