Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Foo {
- Bar? b;
- Bar b2;
- Foo() {
- b.DoSomething(); //valid, but will cause exception
- b2.DoSomething(); //?
- }
- }
- String s = mayBeNull?.toString() ?: "null";
- if (myObj)
- {
- // in this scope, myObj is non-nullable, so can be used
- }
- if (SomeMethodReturningANullable() into anotherObj)
- {
- // anotherObj is non-nullable, so can be used
- }
- string message = GetMessage() into m ? m : "No message available";
- string message = GetMessage() or "No message available";
- class SpecSharpExampleClass
- {
- private string! _nonNullableExampleField;
- public SpecSharpExampleClass(string s)
- : _nonNullableExampleField(s)
- {
- }
- }
- b?->DoSomething();
Add Comment
Please, Sign In to add comment