假设我有以下一组静态函数
在这里,我通过引用发送了变量:
public static void ProcessEmailMessage(ref string HTML)
{
ModifyLinks(ref HTML);
AddFakeImage(ref HTML);
}
public static void ModifyLinks(ref string HTML)
{
//modify HTML links
}
public static void AddFakeImage(ref string HTML)
{
//adds an image to the HTML
}
在这里我按值发送变量
public static string ProcessEmailMessage(string HTML)
{
HTML = ModifyLinks(HTML);
HTML = AddFakeImage(HTML);
return HTML;
}
public static string ModifyLinks(string HTML)
{
//modify HTML links
return HTML;
}
public static string AddFakeImage(string HTML)
{
//adds an image to the HTML
return HTML;
}
哪个更有意义,两者之间是否有任何性能差异?