10个C#编程和Visual Studio使用技巧
2010-10-27 10:49
901 查看
介绍10个C#编程和Visual Studio IDE使用技巧。
1、Environment.Newline
你是否知道这个属性是与平台无关的?允许你根据每个平台输出新的换行字符。
Console.WriteLine("My Tips On ,{0}C#", Environment.NewLine);
2、命名空间别名
你是否知道可以使用更短的别名代替长的命名空间?你是否遇到过需要限制完整的命名空间以避免产生歧义?看下面的代码示例,它是使用扩展的.NET Framework控件创建的一个通用库。
寻找恐怖的数据集合并错误根本原因
StringBuilder error Messages =new StringBuilder();
try
{
DataSet dataSet1 = populateDataSet(1);
DataSet dataSet2 = populateDataSet(2);
dataset1.Merge(dataset2);
}
catch (System.Data.DataException de)
{
foreach (DataTable myTable in dataSet1.Tables)
{
foreach (DataRow myRow in myTable.GetErrors())
{
foreach (DataColumn myColumn in myRow.GetColumnsInError())
{
//loop through each column in the row that has caused the error
//during the bind and show it.
error Messages .Append(string.Format(
"Merge failed due to : {0}", myColumn.GetColumnError(myColumn)));
}
}
}
}
小结
希望你能灵活运用这些C#编程和Visual Studio技巧,享受写代码的乐趣,如果你有其它技巧愿意和大家分享,欢迎在本文后面发表评论。
转自:互联网
本文地址:/article/4961804.html
1、Environment.Newline
你是否知道这个属性是与平台无关的?允许你根据每个平台输出新的换行字符。
Console.WriteLine("My Tips On ,{0}C#", Environment.NewLine);
2、命名空间别名
你是否知道可以使用更短的别名代替长的命名空间?你是否遇到过需要限制完整的命名空间以避免产生歧义?看下面的代码示例,它是使用扩展的.NET Framework控件创建的一个通用库。
寻找恐怖的数据集合并错误根本原因
StringBuilder error Messages =new StringBuilder();
try
{
DataSet dataSet1 = populateDataSet(1);
DataSet dataSet2 = populateDataSet(2);
dataset1.Merge(dataset2);
}
catch (System.Data.DataException de)
{
foreach (DataTable myTable in dataSet1.Tables)
{
foreach (DataRow myRow in myTable.GetErrors())
{
foreach (DataColumn myColumn in myRow.GetColumnsInError())
{
//loop through each column in the row that has caused the error
//during the bind and show it.
error Messages .Append(string.Format(
"Merge failed due to : {0}", myColumn.GetColumnError(myColumn)));
}
}
}
}
小结
希望你能灵活运用这些C#编程和Visual Studio技巧,享受写代码的乐趣,如果你有其它技巧愿意和大家分享,欢迎在本文后面发表评论。
转自:互联网
本文地址:/article/4961804.html
相关文章推荐
- 10个C#编程和Visual Studio 2010 使用技巧
- 10个C#编程和Visual Studio使用技巧
- 10个C#编程和Visual Studio使用技巧
- 10个C#编程和Visual Studio使用技巧
- 【转载】10个C#编程和Visual Studio使用技巧
- 10个C#编程和Visual Studio使用技巧
- 10个C#编程和Visual Studio使用技巧
- 一起谈.NET技术,10个C#编程和Visual Studio使用技巧
- C#编程和Visual Studio使用技巧(下)
- 用C#编程的一些建议(规范写法,使用技巧,少走弯路)ZZ
- C#编程使用技巧
- Visual Studio下使用jQuery的10个技巧
- C#中GDI+编程10个基本技巧二
- Visual Studio下使用jQuery的10个技巧
- C#编程技巧之钩子函数的使用——SetWindowsHookEx
- Visual Studio与C#编程十个实用技巧
- Visual Studio下使用jQuery的10个技巧
- Visual Studio与C#编程十个实用技巧
- Visual Studio下使用jQuery的10个技巧
- Visual Studio下使用jQuery的10个技巧