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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:47:20+00:00 2026-06-17T08:47:20+00:00

I basically want to do something like this public string Password { set {

  • 0

I basically want to do something like this

public string Password
{
  set { password = value; }
}

internal string Password
{
  get { return password; }
}

But without having to call my second function something else (the code above will not compile as I used the name Password twice). I could have setPassword and getPassword, but that seems a bit, well, rubbish 🙁

My scenario is that I’ve a separate assembly (class library) that contains the core business logic. I would not want any projects that use the class library to be able to view the password once set.

  • 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-17T08:47:20+00:00Added an answer on June 17, 2026 at 8:47 am

    It’s as simple as:

    public string Password { internal get; set; }
    

    It’s worth noting that this is an unusual thing to see, and would violate many people’s expectations about properties. While this is possible, it would be preferable to have a public method SetPassword and either an internal field, or an internal GetPassword method. People simply don’t expect to come across a property they can set but not get (even though the reverse is common). This is probably one of the few valid use cases for it, but just to follow the “least surprise” methodology, consider using methods instead.

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

Sidebar

Related Questions

Basically, I want to do something like this (in Python, or similar imperative languages):
I just want to ask if anybody has done something like this. Basically, it's
In short, I want to do something like MyObject myObject; public String getField (String
I basically want something like: TextView Button Button . . . TextView TextView SeekBar
what I want to do is to use something like name=validate[required] basically use it
I'd like to do something like this: Private _myCollection As IList(Of T) Public Property
I have something like this: (pseudocode) public class Author { int id; public List<Thread>
Basically, I want an Html helper (something like @Html.MyEditor(m => m.Property) ) to produce
I want to be able to do something like var XMLquery:String = a1.a2.a3; var
Basically I want to create one large object of many object in JavaScript. Something

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.