Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
Questionclass and object Pin
Member 103106132-Oct-13 0:02
Member 103106132-Oct-13 0:02 
AnswerRe: class and object Pin
Chris Quinn2-Oct-13 0:07
Chris Quinn2-Oct-13 0:07 
AnswerRe: class and object PinPopular
Pete O'Hanlon2-Oct-13 0:09
mvePete O'Hanlon2-Oct-13 0:09 
AnswerRe: class and object Pin
Abhinav S2-Oct-13 0:20
Abhinav S2-Oct-13 0:20 
AnswerRe: class and object Pin
BillWoodruff2-Oct-13 6:16
professionalBillWoodruff2-Oct-13 6:16 
Questiondatatable . help needed Pin
superselector1-Oct-13 18:56
superselector1-Oct-13 18:56 
AnswerRe: datatable . help needed Pin
Abhinav S1-Oct-13 21:09
Abhinav S1-Oct-13 21:09 
AnswerRe: datatable . help needed Pin
Andy_L_J1-Oct-13 22:20
Andy_L_J1-Oct-13 22:20 
Try

C#
System.Data.DataTable dt = new DataTable();
dt.Columns.Add("Class", typeof(System.String));
dt.Columns.Add("Student Details", typeof(System.String));
dt.Columns.Add("School Name", typeof(System.String));
dt.Rows.Add("12", "binod 16 Maths", "X");
dt.Rows.Add("12", "Alex 17 History", "Y");
dt.Rows.Add("12", "Sam 18 Biology", "Z");

DataTable dtNew = new DataTable();
dtNew.Columns.Add("Class", typeof(System.String));
dtNew.Columns.Add("Name", typeof(System.String));
dtNew.Columns.Add("Age", typeof(System.String));
dtNew.Columns.Add("Subject", typeof(System.String));
dtNew.Columns.Add("School Name", typeof(System.String));

foreach (DataRow r in dt.Rows)
{
  string details = (string)r[1];
  string[] row = details.Split(' ');
  dtNew.Rows.Add(r[0], row[0], row[1], row[2], r[2]);
}

foreach (DataRow r in dtNew.Rows)
{
  Console.WriteLine(r[0] + " " + r[1] + " " + r[2] + " " + r[3] + " " + r[4]);
}

Console.ReadKey();

I don't speak Idiot - please talk slowly and clearly

"I have sexdaily. I mean dyslexia. Fcuk!"

Driven to the arms of Heineken by the wife

QuestionExternal component has thrown an exception Pin
Member 102708251-Oct-13 18:13
Member 102708251-Oct-13 18:13 
AnswerRe: External component has thrown an exception Pin
Abhinav S1-Oct-13 20:44
Abhinav S1-Oct-13 20:44 
GeneralRe: External component has thrown an exception Pin
Member 102708252-Oct-13 0:38
Member 102708252-Oct-13 0:38 
GeneralRe: External component has thrown an exception Pin
Dave Kreskowiak2-Oct-13 4:37
mveDave Kreskowiak2-Oct-13 4:37 
GeneralRe: External component has thrown an exception Pin
ramonminarro11-Mar-22 3:10
ramonminarro11-Mar-22 3:10 
GeneralRe: External component has thrown an exception Pin
Dave Kreskowiak11-Mar-22 3:46
mveDave Kreskowiak11-Mar-22 3:46 
QuestionC# assignment please help Pin
bmulgrew11-Oct-13 18:07
professionalbmulgrew11-Oct-13 18:07 
AnswerRe: C# assignment please help Pin
Abhinav S1-Oct-13 21:10
Abhinav S1-Oct-13 21:10 
AnswerRe: C# assignment please help Pin
OriginalGriff1-Oct-13 21:25
mveOriginalGriff1-Oct-13 21:25 
GeneralDestructors Pin
N8tiv1-Oct-13 15:34
N8tiv1-Oct-13 15:34 
GeneralRe: Destructors Pin
Richard Andrew x641-Oct-13 16:29
professionalRichard Andrew x641-Oct-13 16:29 
GeneralRe: Destructors Pin
N8tiv1-Oct-13 16:31
N8tiv1-Oct-13 16:31 
GeneralRe: Destructors Pin
Richard Andrew x641-Oct-13 17:09
professionalRichard Andrew x641-Oct-13 17:09 
GeneralRe: Destructors Pin
Dave Kreskowiak1-Oct-13 17:05
mveDave Kreskowiak1-Oct-13 17:05 
GeneralRe: Destructors Pin
Richard Andrew x641-Oct-13 17:08
professionalRichard Andrew x641-Oct-13 17:08 
GeneralRe: Destructors Pin
Keith Barrow1-Oct-13 22:45
professionalKeith Barrow1-Oct-13 22:45 
GeneralRe: Destructors Pin
N8tiv1-Oct-13 19:56
N8tiv1-Oct-13 19:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.