Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
public string MO_Number { get  ;set ;} = "" ;


What I have tried:

C#
Private string r = String.Empty;

public string MO_Number { get  ;set ;}
  public string r 
    { 
        get 
        { 
            if (String.IsNullOrEmpty(this.r)) 
                return this.MO_Number ;   

            return this.r; 
        } 

        set { this.r = value; } 
    }


Thank you for you help :) .
Posted
Updated 31-Mar-17 1:16am
Comments
[no name] 31-Mar-17 7:09am    
Why did you create 2 properties where one would do?

1 solution

private string _mo_number = ""; // should use string.Empty instead of "" though

public string MO_Number
{
    get
    {
        return _mo_number;
    }
    set
    {
        _mo_number = value;
    }
}
 
Share this answer
 
v2
Comments
EM_Y 31-Mar-17 7:40am    
Thank you I will try it and tell you the result !
EM_Y 31-Mar-17 9:27am    
Should I do the same with 1,2 and 3 , Or it needs another Code structure !?


1. public static int supplierCode { get; private set; } = int.Parse(ConfigurationManager.AppSettings.Get("supplierCode"));

2. public List<string> alreadyScannedSubsets { get; set; } = new List<string>();

3. Dictionary<string, Delegate> SequencerInputs {get; set;} = null;


Thank you for your help ,Bless you :) .
F-ES Sitecore 31-Mar-17 9:53am    
You can do the same with 1 and 2, but 3 just needs

Dictionary<string, Delegate> SequencerInputs {get; set;} = null;

The "= null" sets the default value for the property, but the default Dictionary is null anyway.
EM_Y 31-Mar-17 10:04am    
Your are brilliant ^^ thank you .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900