set in model class is not functionnal!

sblb 1,231 Reputation points
2022-08-18T16:41:54.957+00:00

Hi, I have the class model below and when the condition DTb is verified Statut take the "Open".
When the Status of the DTb changes my app is blocked. Is not possible to use dev tool because the application is blocked.

public string CloseOn { get; private set; }  
        public string Statut  
        {  
              
         get  
           {  
              if (DTb != "Validated")  
                  {  
                      string var1;  
                       var1 = "Open";  
                      return var1;  
                 }  
               return Statut;  
            }  
         set  
            {                  
                   if (DTb == "Validated")  
                   {  
                     CloseOn = "Closed";  
                   }  
                  
            }  
                 
        }  

Is the model class I wrote correct?
Have you an idea why my application is blocked ?
Thanks in advance

Developer technologies | .NET | Blazor
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Viorel 125.7K Reputation points
    2022-08-18T16:47:01.66+00:00

    I think that the 'return Statut' calls Statut again and again (infinitely or until an overflow error). This blocks your application.

    You should return something else. (Maybe 'return CloseOn'?).


1 additional answer

Sort by: Most helpful
  1. AgaveJoe 30,411 Reputation points
    2022-08-18T20:21:15.017+00:00

    You have to understand the code you've shared is nonsensical. Therefore, the community is unable to infer your intent from the code. Please explain the use case and perhaps the community can provide a logical approach.

    The C# programming guide has a section on properties which might prove helpful.

    Properties (C# Programming Guide)

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.