Conversion between data types of C # manipulation techniques

Source: Internet
Author: User
Tags functions tostring
Skills | data | data type | conversion

We are in the VB data type between the conversion is very easy cstr,cint and so on functions, we all in use time should have been
is very clear, now you can use C # to do Web applications! Now we have a choice of language, plus there are really a lot of people
VB programming has a lot of do not understand: (, so they prefer to use C # programming, there are a lot of comrades stand not firm! Also want to learn to learn C #
Language (for example: Tofu. In this way, the problem of data conversion is emergent! In addition, there are conversions to string data types
First, let's look at the conversion between int and string.
Int->string, using the ToString function, let's take a look at this example 1.ToString (), for God's sake, this syntax can be identified by:
That's the C # language.
String->int has a lot of choices (actually one), such as: "12345". ToInt16 (), functions, and, of course, toint32,toint64, etc.
Similar functions, the usage is the same

How to convert a string to an array type based on a specified rule, "Http://www.asp888.net Tofu Technology Station". Split ("". Tochararay ())

How to convert a specified string to another string in a string, for example: Convert "'" to ""
We need to introduce a new Class StringBuilder here, let's take a look at this function
<script language= "C #" runat=server>
function replacestr1tostr2 (String str1,string str2,string str3) {
STR1 is the original string containing the string to replace
STR2 is the string to replace
STR3 is to replace str2 with STR3
StringBuilder d=new StringBuilder (STR1);
D=d.replace (STR2,STR3);
return d.tostring ();
}
</script>
Then we can process the "'" Symbol by REPLACESTR1TOSTR2 (str, "'", "") while processing the SQL statement! Other than that
You can also use REPLACESTR1TOSTR2 (str, "\ n", "<br>") to handle the return of the output data!!!



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.