Skip to content

Commit b76c412

Browse files
Rename Foo and Bar classes
1 parent 5ae9ee7 commit b76c412

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

docs/csharp/nullable-references.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -386,42 +386,42 @@ Constructor of a class will still call the finalizer, even when there was an exc
386386
<br/>The following example demonstrates that behavior:
387387

388388
```csharp
389-
public class Foo
389+
public class A
390390
{
391391
private string _name;
392-
private Bar _bar;
392+
private Disposable _b;
393393

394-
public Foo(string name)
394+
public A(string name)
395395
{
396396
ArgumentNullException.ThrowIfNullOrEmpty(name);
397397
_name = name;
398-
_bar = new Bar();
398+
_b = new B();
399399
}
400400

401-
~Foo()
401+
~A()
402402
{
403403
Dispose();
404404
}
405405

406406
public void Dispose()
407407
{
408-
_bar.Dispose();
408+
_b.Dispose();
409409
GC.SuppressFinalize(this);
410410
}
411411
}
412412

413-
public class Bar: IDisposable
413+
public class B: IDisposable
414414
{
415415
public void Dispose() { }
416416
}
417417

418418
public void Main()
419419
{
420-
var foo = new Foo(string.Empty);
420+
var a = new A(string.Empty);
421421
}
422422
```
423423

424-
In the preceding example, the <xref:System.NullReferenceException?displayProperty=nameWithType> will be thrown when `_bar.Dispose();` runs, if the `name` parameter was `null`. The call to `_bar.Dispose();` won't ever throw when the constructor completes successfully.
424+
In the preceding example, the <xref:System.NullReferenceException?displayProperty=nameWithType> will be thrown when `_b.Dispose();` runs, if the `name` parameter was `null`. The call to `_b.Dispose();` won't ever throw when the constructor completes successfully.
425425

426426
However, there's no warning issued by the compiler, because static analysis can't determine if a method (like a constructor) completes without a runtime exception being thrown.
427427

0 commit comments

Comments
 (0)