DatabaseExtensionsToChar Method

This is used to convert a string value to a nullable Char by returning null if the string is null or empty or the first character of the string if not.

Definition

Namespace: EWSoftware.EntityFramework
Assembly: EWSoftware.EntityFramework (in EWSoftware.EntityFramework.dll) Version: 2025.11.12.0
public static char? ToChar(
	this string? value
)

Parameters

value  String
The value to check

Return Value

NullableChar
If the value is null or an empty string, this returns null. If not, it returns the first character of the string.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type String. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Example

C#
using var dataContext = new MyDbContext();

dataContext.spAddName(txtLastName.Text, txtFirstName.Text.NullIfWhiteSpace(),
    txtRace.Text.ToChar(), txtSex.Text.ToChar(),
    dtpDOB.BindableValue.ToNullable<DateTime>());

See Also