Click here to Skip to main content
15,904,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a data set as follows:

C#
namespace user_control_typed_dataset
{


   partial class Studentdataset
   {

        public string Name{get;set;}
        public string ID { get; set; }
        public string Address { get; set;}

        private void InitializeComponent()
        {


        }

    }
}


i want to print the field names Name,ID and Address.But when i'm using field info property,i'm getting so many other field too and intead of Name ,i'm getting <name> backing_field.But i want Name only.How to solve this.Pls help me.
Posted
Updated 18-Aug-13 19:09pm
v2

Here is a small example for you

DataTable table = new DataTable();
table.Columns.Add("Employee", typeof(string));
table.Columns.Add("ID", typeof(string));

table.Rows.Add("Xing Zuber", "1");
table.Rows.Add("Daving solman", "2");
table.Rows.Add("Iyan Yokovich", "3");
table.Rows.Add("Dev richardson", "4");
table.Rows.Add("Jeanson ", "5");

string[] columnNames = table.Columns.Cast<datacolumn>()
.Select(x => x.ColumnName)
.ToArray();


foreach (string dc in columnNames)
{
string st = dc.ToString();
}
 
Share this answer
 
C#
Studentdataset student = new Studentdataset();
studentProperties = student.GetType().GetProperties();
foreach (var propertyInfo in studentProperties)
{
  Consol.WriteLine(propertyInfo.Name);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900