Friday

C#(csharp) how to resize array (shrink) by Array.Copy

 

/// <summary>
/// Emails addresses creating.
/// </summary>
/// <param name="incom">The incoming array</param>
/// <returns></returns>
private EmailAddressType[] EmailAddressCreate(string[] incom) {
if (incom == null) return null;
EmailAddressType[] ret = new EmailAddressType[incom.Length];
EmailAddressType[] rt;
int i = 0;
foreach (string s in incom) {
if (!string.IsNullOrEmpty(s))
{
ret[i] = new EmailAddressType();
ret[i].EmailAddress = s;
i++;
}
}
// change size of array
if (i < incom.Length)
{
rt = new EmailAddressType[incom.Length];
Array.Copy(rt, ret, i);
}else
{
rt=ret;
}

return rt;
}

more...

No comments:

imagemagic add text to image

rem different types of text annotations on existing images rem cyan yellow orange gold rem -gravity SouthWest rem draw text and anno...