EmptyToNull Guid(?), string

.EmptyToNull()

Converts an empty value to null.

Method

public static Guid? EmptyToNull(this Guid val)
public static Guid? EmptyToNull(this Guid? val)
public static string EmptyToNull(this string val)
Guid(?) val

Guid or Guid? value to test if Empty GUID {00000000-0000-0000-0000-000000000000} and then convert to null if so, else return the GUID value.

string val

String value to test if Empty string "" and then convert to null if so, else return the string value.

Example

C#
var g = Guid.Empty();
Guid? result = g.EmptyToNull();