Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,914 questions

51,847 answers

573 users

How to print specific row in DataTable with C#

1 Answer

0 votes
using System;
using System.Data;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main()
        {
            DataTable table = new DataTable();

            table.Columns.Add("ID", typeof(int));
            table.Columns.Add("Name", typeof(string));
            table.Columns.Add("Salary", typeof(double));

            table.Rows.Add(123, "Ajax", 23492);
            table.Rows.Add(543, "Arrow", 31871);
            table.Rows.Add(876, "Axel", 16878);
            table.Rows.Add(342, "Everly", 46123);

            DataRow dataRow = table.Rows[1];

            foreach (var item in dataRow.ItemArray) {
                    Console.Write("{0} ", item);
            }
            Console.WriteLine();
        }
    }
}


/*
run:
   
543 Arrow 31871
 
*/

 



answered Aug 23, 2018 by avibootz

Related questions

1 answer 168 views
1 answer 348 views
1 answer 139 views
1 answer 134 views
1 answer 90 views
90 views asked Jul 30, 2023 by avibootz
1 answer 147 views
3 answers 165 views
...