Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6361879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:50:03+00:00 2026-05-24T23:50:03+00:00

I have a DataTable which has 4 columns. I want to change the 3rd

  • 0

I have a DataTable which has 4 columns. I want to change the 3rd column’s value as “0”.
Below is my DataTable.

ID             Name            Value      Type
----            ----            -----      -----
1              Sam              250        2
2              Rai              324        3
3              Tim              985        8

My Desired Result should be like below:

 ID             Name            Value     Type
----            ----            -----     ------
1              Sam              0          2
2              Rai              0          3
3              Tim              0          8

How to achieve this without looping? Any suggestions please.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:50:04+00:00Added an answer on May 24, 2026 at 11:50 pm

    How about this? ↓ without loop….

    static void Main(string[] args)
    {
        DataTable table = new DataTable();
    
        table.Columns.Add("col1");
        table.Columns.Add("col2");
    
        table.Rows.Add(new object[] { "1", "1" });
        table.Rows.Add(new object[] { "1", "1" });
        table.Rows.Add(new object[] { "1", "1" });
        table.Rows.Add(new object[] { "1", "1" });
    
        foreach (DataRow row in table.Rows)
            Console.WriteLine(row["col2"].ToString());
    
        Console.WriteLine("***************************************");
    
        DataColumn dc = new DataColumn("col2");
        dc.DataType = typeof(int);
        dc.DefaultValue = 0;
    
        table.Columns.Remove("col2");
        table.Columns.Add(dc);
    
        foreach (DataRow row in table.Rows)
            Console.WriteLine(row["col2"].ToString());
    
    
        Console.ReadKey();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dataTable which has the column Device Type,DeviceName and label. There can
I have a DataTable which has 5 columns: ID Name Account Number Branch Amount
I have this table which has seven columns, each column representing a specific value
I have a datatable which loops through a List and has a value column
I have a datatable which has an amount column & a status column. I
I have a DataTable which has 10 columns, and after I add some rows
I have a DataTable which is bound to DataGridView . DataTable has several columns
I have one datatable which has four or five columns. I dont know exactly
I have a form with a dataTable which has various columns having links and
I have a datatable I'm using which has 5 columns ( http://datatables.net/ ) The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.