我有这样一段代码:
string suffix = "wallpapers\\";
string extenstion = ".jpg";
string[] wallpapers;
.....
void SetWallPapers()
{
wallpapers = new string[] {
suffix + "1" + extenstion,
suffix + "2" + extenstion,
suffix + "3" + extenstion,
suffix + "4" + extenstion,
};
}
是否有任何变体可以在数组内容中进行 lambda 声明,例如:
(伪代码,仅供参考!)
wallpapers = new string[] { ( () => { for i = 1 till 4 -> suffix + i + extension; } ) }
有什么建议么?