Add only non null XElements

Date: 2020-08-12
public IEnumerable<XElement> GetElements(string[,] parameters)
{
	for (int i = 0; i < parameters.GetLength(0); i += 1)
	{
		var key = parameters[i, 0];
		var value = parameters[i, 1];
		if (string.IsNullOrEmpty(value))
			continue;
		yield return new XElement(key, new XText(value));
	}
}
// usage:
var message = new XElement("Message",
		GetElements(new string[,] {
			{ "Title", "The title" },
			{ "Content", "The content" }
			{ "NotIncluded", null }
		})
	);
38960cookie-checkAdd only non null XElements