C # how to generate Type parameters when creating a DataColumn class,

Source: Internet
Author: User

C # how to generate Type parameters when creating a DataColumn class,
The following constructor is required for the DataColumn class:

//// Summary: // use the specified column name and Data type to initialize a new instance of the System. Data. DataColumn class. //// Parameter: // columnName: // a string that indicates the name of the column to be created. If it is set to null or an empty string (""), a default name is specified when it is added to the column set. //// DataType: // supported System. Data. DataColumn. DataType. //// Exception: // System. ArgumentNullException: // No ype is specified. Public DataColumn (string columnName, Type dataType); // Abstract: // use the specified name, Data Type, and expression to initialize a new instance of the System. Data. DataColumn class. //// Parameter: // columnName: // a string that indicates the name of the column to be created. If it is set to null or an empty string (""), a default name is specified when it is added to the column set. //// DataType: // supported System. Data. DataColumn. DataType. //// Expr: // the expression used to create the column. For more information, see System. Data. DataColumn. Expression attributes. //// Exception: // System. ArgumentNullException: // No ype is specified. Public DataColumn (string columnName, Type dataType, string expr); // Abstract: // use the specified name, data Type, expression, and value to determine whether the column is an attribute, initialize System. data. A new instance of the DataColumn class. //// Parameter: // columnName: // a string that indicates the name of the column to be created. If it is set to null or an empty string (""), a default name is specified when it is added to the column set. //// DataType: // supported System. Data. DataColumn. DataType. //// Expr: // the expression used to create the column. For more information, see System. Data. DataColumn. Expression attributes. //// Type: // one of the values of System. Data. MappingType. //// Exception: // System. ArgumentNullException: // No ype is specified. Public DataColumn (string columnName, Type dataType, string expr, MappingType type );
C # several types of statements related to Type 1, typeof
Typeof is an operator, typeof (type ). For example, typeof (bool), typeof (int), typeof (System. Windows. Forms. TextBox)
2. Type. GetType (Type name ). This type name is string type and enclosed in quotation marks.
3. Object. GetType (). This method is available for class objects of the Object Class c.
System. Type is returned for all the three above.
Example:
Private void Form1_Load (object sender, EventArgs e) {try {dt = new DataTable (); dt. columns. add (new DataColumn ("one", System. type. getType ("System. double "); // System. type. getType (TypeCode. double. toString () cannot use dt. columns. add (new DataColumn ("two", System. type. getType ("System. double "); dt. columns. add (new DataColumn ("three", typeof (Double); dt. columns. add (new DataColumn ("four", (1D ). getType (); Random rnd = new Random (); for (int I = 0; I <10; I ++) {dt. rows. add (new object [] {(Double) rnd. next (1, 234923745), (Double) rnd. next (1, 234923745), (Double) rnd. next (1, 234923745), (Double) rnd. next (1, 234923745)});} dt. defaultView. sort = "one ASC, two ASC"; dataGridView1.DataSource = dt. defaultView;} catch (System. exception ex) {MessageBox. show (ex. message );}}
Source code download: c # DataGridView data binding example multi-column hybrid sorting


In the C language, what is the symbol (->) and how to use it?

This is a symbol in the struct pointer. Write a program to explain it, for example:
# Include <stdio. h>
Struct STU // define a struct
{
Int num;
} Stu;
Int main ()
{
Struct STU * p; // defines a struct pointer.
P = stu; // p points to the struct variable stu.
Stu. num = 100; // attaches an initial value to the struct member num.
Printf ("% d", p-> num); // output the num value in stu
Return;
}
As you can see, the-> method is to reference the variable in the struct !!
Format: p-> struct member (such as p-> num)
The function is equivalent to stu. num or (* p). num.
I don't know. You don't understand, and don't understand call me. O (∩ _ ∩) O ~
Hope to adopt it.

In the C language, what is the symbol (->) and how to use it?

This is a symbol in the struct pointer. Write a program to explain it, for example:
# Include <stdio. h>
Struct STU // define a struct
{
Int num;
} Stu;
Int main ()
{
Struct STU * p; // defines a struct pointer.
P = stu; // p points to the struct variable stu.
Stu. num = 100; // attaches an initial value to the struct member num.
Printf ("% d", p-> num); // output the num value in stu
Return;
}
As you can see, the-> method is to reference the variable in the struct !!
Format: p-> struct member (such as p-> num)
The function is equivalent to stu. num or (* p). num.
I don't know. You don't understand, and don't understand call me. O (∩ _ ∩) O ~
Hope to adopt it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.