Skip to the content.

< Back


MyNullableClass

Namespace: MyClassLib

Showcases nullable reference types and named-tuple element rendering.

public class MyNullableClass

Inheritance ObjectMyNullableClass
Attributes NullableContextAttribute, NullableAttribute

Fields

OptionalNames

A field with a nullable generic type argument.

public IEnumerable<string?>? OptionalNames;

Properties

OptionalName

A nullable-reference property.

public string? OptionalName { get; set; }

Property Value

String

RequiredName

A non-nullable-reference property (annotation should NOT add a ?).

public string RequiredName { get; set; }

Property Value

String

Counter

A value-type Nullable property — renders as int?, not Nullable<int>.

public int? Counter { get; set; }

Property Value

Int32?

Constructors

MyNullableClass()

public MyNullableClass()

Methods

Origin()

Returns a named tuple.

public (int X, int Y) Origin()

Returns

(Int32 X, Int32 Y)
A named (X, Y) pair.

Describe((String, Int32), (Int32, Int32))

Accepts a named tuple parameter and an unnamed tuple parameter.

public string Describe((string Name, int Age) point, (int, int) pair)

Parameters

point (String Name, Int32 Age)
A named pair.

pair (Int32, Int32)
A positional pair.

Returns

String
A descriptive label.

Echo(String)

Nullable-reference parameter and nullable-reference return.

public string? Echo(string? input)

Parameters

input String?
Possibly null input.

Returns

String?
Possibly null output.


< Back