This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void Foo(string? bar) | |
| { | |
| if (!bar.IsNullOrEmpty()) | |
| { | |
| var length = bar!.Length; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void Foo(string? bar) | |
| { | |
| if (!bar.IsNullOrEmpty()) | |
| { | |
| var length = bar.Length; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| string? nullableString = "hello"; | |
| string nonNullableString = nullableString; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public int CalculateSquareOfAge(Person? p) | |
| { | |
| int age = p?.Age ?? 0; | |
| return age * age; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public int CalculateSquareOfAge(Person? p) | |
| { | |
| var result = 0; | |
| if (p != null) | |
| result = p.Age * p.Age; | |
| return result; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public int CalculateSquareOfAge(Person? p) | |
| { | |
| int age = p.Age; | |
| return age * age; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public int CalculateSquareOfAge(Person p) | |
| { | |
| int age = p.Age; | |
| return age * age; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface IDisplayService | |
| { | |
| void DisplayMessage(string message) { WriteLine(message); } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int x = int.Parse(Console.Readline()); | |
| if (x.Even) | |
| { | |
| Console.WriteLine("You’ve typed an even number."); | |
| } |
NewerOlder