

控件填充窗体的方式跟Z order有关。后放上去的控件Dock属性选了Fill也只好被挤在中间。DateTime.toString()里的格式化串中,d表示一位日期,dd表示可补0的两位,而ddd表示周三的”三”,dddd则干脆返回”星期三”。
另附C#生成重复字符串的三种方式:
//用StringBuilder的,据说比简单重复相加效率高些:
static string StringRepeat(string str, int n)
{
if (String.IsNullOrEmpty(str) || n <= 0)
return str;
StringBuilder sb = new StringBuilder();
while (n > 0)
{
sb.Append(str);
n--;
}
return sb.ToString();
}
//用递归方式的,有趣:
string Build(string value, int count)
{
string outValue = value;
if (count > 1)
{
outValue += Build(value, count - 1);
}
return outValue;
}
//据说内存效率最高的:
public static string RepeatString(string str, int n)
{
char[] arr = str.ToCharArray();
char[] arrDest = new char[arr.Length * n];
for (int i= 0; i < n; i++)
Buffer.BlockCopy(arr, 0, arrDest, i * arr.Length * 2, arr.Length * 2);
return new string(arrDest);
}
原创文章,作者:苏葳,如需转载,请注明出处:https://www.swmemo.com/195.html
