Char to String
Can anyone please help me with what should be a simple line of code
I would like to create some columns in a datatable called 'Column A' etc, and I am using this code to try to do create the name.
string ColumnName;
for (int counter = 1; counter <= 26; counter++)
ColumnName = "Column " + Convert.ToString((char) counter + 64);
What happens is the ColumnName holds 'Column 65'. It does not seem to be seeing (char).
If I change the code to the following then it works fine, but thats not how I want to do it. Any ideas on what I am doing wrong please?
string ColumnName;
for (int counter = 65; counter <= 90; counter++)
ColumnName = "Column " + Convert.ToString((char) counter);
Vimal KandasamyPosted Mar 14, 2009, 12:12 AM
for (int counter = 1; counter <= 26; counter++)
{
ColumnName = "Column " + Convert.ToString((char)(counter + 64));
}
try this
Grant McConvillePosted Mar 13, 2009, 4:26 PM
Vimal KandasamyPosted Mar 13, 2009, 5:58 AM
what u need exactly?
Column 65,Column 66 etc
[generated by your 1st code]
or
Column A,Column B..
[generated by your 2nd code]
if u need Column A,Column B..it will be generatd your second code... what is the problem in that?