set in model class is not functionnal!

sblb 1,166 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

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,403 questions
C#
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.
10,307 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 112.5K 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 26,146 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