Can you interrupt the established ownership procedure

I am programming in C # .NET. Is it possible to interrupt the established procedure of a class property without exception?

Here is what I want to do ...

public int RandomProperty
{
    set
    {
     DialogResult answer = new DialogResult();
     answer = MessageBox.Show("This process could take up to 5 min. Are you sure you want to continue?");
     if(answer = DialogResult.No) 
        CancelSet   // Can I do something similar here?
     else
     {
      ...Do set procedure
     }
    }
}

I don’t think I can use a method (instead of a property) because I set this value using the grid property.

+3
source share
5 answers

. -. . , , , . . .

, . , , ? , "". , , , , .

, , .

, , , " , ", " " " , ". "", , . , , , .

, - . , .

+8

IMO, - , set , . ( -) , set, . , :

public bool TrySetRandomProperty(SomeType value) {
    ...
}

true false, , . ; , , , ?

+12

. ? ?

+3

, , , .

, .

.

+2

. , , , "cancel" .

+1
source

Source: https://habr.com/ru/post/1733224/


All Articles