I was searching earlier and saw that many people's solution to this issue is implementing a for loop. No need with >= c#2.0 List has a very handy ConvertAll method.
I have a quick example of the awesome power in 2 lines of code.Convert List<int> into a List<string> or List<int> into an array of strings which I needed to join a list of ids.
List<int> myList = new List<int>(){ 101,202,332,343};
string sIdList = string.Join(",", myList.ConvertAll<string>(delegate(int i){return i.ToString();}).ToArray());
sIdList output is "101,202,332,343"
I hope this helps someone else.
Wednesday, February 25, 2009
Monday, February 2, 2009
SQL Server 2008 Edit Top 200 Rows
I thought this feature was fixed, but glad to see that you can override very easily in the SQL Object Browser interface. Tools - Options - Sql Server Object Explorer
Labels:
Edit All,
Edit Top 200 Rows,
Select All,
SQL Server 2008
C# DataTable with Custom Objects
Came across this little tidbit to allowing custom object types in a .net DataTable. Issue being that if you don't set the property, you get the string value of the object.
DataTable dt = new DataTable();
DataColumn dcMyObject = new DataColumn("MyObject");
dcMyObject.DataType = typeof("MyNameSpace.MyClass");
dt.Columns.Add(dcMyObject);
DataColumn dcMyObject = new DataColumn("MyObject");
dcMyObject.DataType = typeof("MyNameSpace.MyClass");
dt.Columns.Add(dcMyObject);
Subscribe to:
Comments (Atom)