Stick to Learning asp.net--(52)

Source: Internet
Author: User
Tags arrays definition class definition tostring
asp.net when data is converted to a ASP.net page, most of them are in the form of text. Sometimes in order to output, only use the display or implicit conversion is not, you need this section of the data conversion.

String output:

int intage=21;

String strage=intage.tostring ();

When you convert a datetime value, you can specify the output style for the time by placing an optional argument within the parentheses. Eg:dateCou.ToString ("D");

Format code and its implication:

d--is given in the following format: Thursday,september 21,2001

g--09/22/2001 09:12:23

t--give the time: 01:23:22 minutes and seconds

t--Give time: 01:23

D--mm/dd/yyyy

Data entry

convert function Encyclopedia:

Convert.toboolean ();
Convert.tobyte ();
Convert.tochar ();
Convert.todatetime ();
Convert.todecimal ();
Convert.todouble ();
Convert.ToInt16 ();
Convert.ToInt32 ();
Convert.toint64 ();
Convert.tosbyte ();
Convert.tosingle ();
Convert.touint16 ();
Convert.touint32 ();
Convert.touint64 ();


Seven, constant

Assignment: const int absolutezero=-273;

Must be declared in the class definition, not detached from the class.

VIII. Structured data types

1, array

Declares an array: string [] strsz;

In order to generate a declared array, it must be initialized: Strsz=new string[5];

Simultaneous initialization of the declaration: string [] asp=new string[44];

The subscript of the array starts with 0.

Assignment of variable: asp[0]= "SDF";

Asp[2]= "SDF";

......

Or:

string [] asp=new string[]{"asdf", "Asdfas"};

string [] asp=new string[2]{"asdf", "Asdfas"};

string [] asp={"asdf", "Asdfas"};

See examples:

<script runat= "Server" language= "C #" >
void Page_Load ()
{
string[] strarraydetails = new String[3];
int intloop;

Strarraydetails[0] = Text1. Text;
STRARRAYDETAILS[1] = Text2. Text;
STRARRAYDETAILS[2] = Text3. Text;

Message1.text = Strarraydetails[0];
Message2.text = strarraydetails[1];
Message3.text = strarraydetails[2];

}
</script>

<title>text Box example</title>
<body>
<asp:label id= "Message1" runat= "Server"/>
<br/>
<asp:label id= "Message2" runat= "Server"/>
<br/>
<asp:label id= "Message3" runat= "Server"/>
<br/>
<form runat= "Server" >
Please enter your name:
<asp:textbox id= "Text1" runat= "Server"/>
<br/><br/>
Please enter your address:
<asp:textbox id= "Text2" runat= "Server" rows=5 textmode= "Multiline"/>
<br/><br/>
Please enter your chosen password:
<asp:textbox id= "Text3" runat= "server" textmode= "password"/>
<br/><br/>
<input type= "Submit" >
</form>
</body>


Multidimensional Arrays:

string [,] strstr1=new string[3,2];

C # does not limit the size of the array, only memory to limit it, but in practice, when there are more than three-dimensional arrays, you need to consider other solutions, such as objects.

Irregular arrays:

string [] strnre=new string[2][];

String Strnre[0]=new string[8];

String Strnre[1]=new string[2];

2, structure

Definition: struct nameabc{...};

3, enumeration

Enum gender{male=0,female=1};

We'll learn XML together in the next chapter.



Finally found the teaching material I now study the online address:

Http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764543709,descCd-download_code.html

Interested friends do not seek to learn together.




Related Article

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.