You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

safety-cast-pass.cs 447 B

12345678910
  1. private void MyFunction(IMessage message)
  2. {
  3. // Here we do the reverse as in the previous examples, and let it continue the code below if it IS an IUserMessage
  4. if (message is not IUserMessage userMessage)
  5. return;
  6. // Because we do the above check inline (don't give the statement a body),
  7. // the code will still declare `userMessage` as available outside of the above statement.
  8. Console.WriteLine(userMessage.Author);
  9. }