I have written a utility function:
public static void SerializeErrorMessage(int ErrorCode, string ErrorMessage, out byte[] Buffer)
{
object ErrorJson = new { ErrorCode, ErrorMessage };
string Serialized = JsonConvert.SerializeObject(ErrorJson);
Buffer = Encoding.UTF8.GetBytes(Serialized);
}
I'm wondering why I should/shouldn't have written it like this instead:
public static byte[] SerializeErrorMessage(int ErrorCode, string ErrorMessage)
{
object ErrorJson = new { ErrorCode, ErrorMessage };
string Serialized = JsonConvert.SerializeObject(ErrorJson);
byte[] Buffer = Encoding.UTF8.GetBytes(Serialized);
return Buffer;
}
Is it just a matter of personal preference? Is the first function more performant than the second function?