با عرض سلام و خسته نباشید خدمت کاربران وب سایت پروگرم 98 😉 در این مطلب آموزش افزودن ستون به DataTable در #C را آماده کردم. انشاالله که این کد سی شارپ براتون مفید باشد.
کد افزودن ستون به DataTable در #C :
using System;
using System.Data;
class Program
{
static void Main(string[] args)
{
DataTable dt1 = new DataTable("Table-1");
DataColumn pkCol = dt1.Columns.Add("Id", typeof(int));
dt1.Columns.Add("Field1", typeof(string)).MaxLength = 50;
dt1.PrimaryKey = new DataColumn[] { pkCol };
using System.Data;
class Program
{
static void Main(string[] args)
{
DataTable dt1 = new DataTable("Table-1");
DataColumn pkCol = dt1.Columns.Add("Id", typeof(int));
dt1.Columns.Add("Field1", typeof(string)).MaxLength = 50;
dt1.PrimaryKey = new DataColumn[] { pkCol };