what does this string.format piece of code do?

Posted by jbkkd on Stack Overflow See other posts from Stack Overflow or by jbkkd
Published on 2010-03-28T11:35:08Z Indexed on 2010/03/28 11:43 UTC
Read the original article Hit count: 150

Filed under:
|

I have this piece of code in c#:

private static void _constructRow(SqlDataReader reader, system.IO.StreamWriter stwr, bool getColumnName)
{
  for (int i = 0; i < reader.FieldCount; i++)
   stwr.Writeline(String.Format("<td>{0}</td"), getColumnName ? reader.GetName(i) : reader.GetValue(i).ToString()));
}

I'm trying to understand what the part that start with "getColumnName ?" and ends with ".ToString()" does. I understood that it is a system.object type, but I have no idea what it specifically does or how it works. I want that because of this: "reader" had multiple rows in it, and I want to writeline only specific rows.

If anyone can help me on either of those, I'd be grateful.

© Stack Overflow or respective owner

Related posts about c#

Related posts about string.format