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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:57:27+00:00 2026-06-01T22:57:27+00:00

I have simple scenario where I have AnotherTest value based on Test value. This

  • 0

I have simple scenario where I have AnotherTest value based on Test value. This works fine most of the time so that whenever I provide Test I am sure to get AnotherTest easily.

public sealed class Transaction {
    public string Test { get;set; }
    public string AnotherTest{
        get {
            int indexLiteryS = Test.IndexOf("S");
            return Test.Substring(indexLiteryS, 4);
        }
    }
}

However I wanted to be able to also set AnotherTest value and be able to read it without having to provide Test value. Is this possible? So kinda 2 types of get based which way it was set. I know I could create 3rdTest but I have some methods that use AnotherTest and other fields and I would have to write overloads of that methods.

Edit:

I read some file supplied by bank. I cut it in pieces put some stuff in Test value and every other field (AnotherTest and similar) of the Transaction gets filled automatically.
However later on I would like to read Transaction from SQL that is already in nice format so I don’t need to provide Test to get the rest of the fields. I would like to set those fields with set and then be able to use get without setting Test value.

  • 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-01T22:57:29+00:00Added an answer on June 1, 2026 at 10:57 pm

    Yes, like so:

    public string Test { get; set; }
    
    public string AnotherTest
    {
       get
       {
          if(_anotherTest != null || Test == null)
             return _anotherTest;
    
          int indexLiteryS = Test.IndexOf("S")
          return Test.Substring(indexLiteryS, 4);
       }
       set { _anotherTest = value; }
    }
    private string _anotherTest;
    

    That getter could also be expressed as

    return (_anotherTest != null || Test == null)
        ? _anotherTest
        : Test.Substring(Test.IndexOf("S"), 4);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have some simple Export/Import Scenario that i can't figur out why this not
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Pretty simple scenario. I have a web service that receives a byte array that
I have a quite simple scenario that I cannot get to work correctly. I
I have a simple (actually simplified :) ) scenario that is possibly the cause
I have a simple scenario that may or may not be possible. I have
I have what seems to be a fairly simple scenario that I am trying
I have (what I feel to be) a very simple scenario that I can't
I have this simple scenario: main.m (which is my main class) myClass.m (which is
I have a simple scenario below it works in XP ie6 but doesn't work

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.