Basic Learning of C #

Source: Internet
Author: User
Tags foreach bool numeric php foreach

This is a C # Basic learning article, the master can skip,

1. Basic type:

Basically the same as c\c++

Decimal decimal is a 128-bit high precision floating-point number.

BOOL Note that the BOOL type has only true and faulse two desirable values, in C #, the bool value cannot be cast to an integer value. For example, it is not possible to convert true to 1 or convert 1, 0 to bool values.

Parse and TryParse conversion strings

Basic numeric types contain parse and TryParse methods that convert numeric string types to the specified number type, such as

int iParse = Int32.Parse("1000");
float fParse = float.Parse("1.2"');

TryParse can provide conditional parsing, which returns a Boolean value to indicate whether the resolution was successful, eliminating the hassle of adding a field to handle the code.

int result;
book ok = Int32.TryParse("100" , out result);

2. Control structure

It's basically the same as c\c++, with a foreach loop, which is equivalent to a PHP foreach, but the collection Class (collections) in. NET can be used in a foreach loop.

3. Preprocessing instructions

Similar to c\c++, the most common uses are conditional compilation, increased diagnostics to report errors and warnings, and defining code domains.

(1) Conditional compilation

#define DEBUG
using System;
public class MyApp
{
public static void Main()
{
#if(DEBUG)
Console.WriteLine("Debug Mode");
#else
Console.WriteLine("Release Mode");
#endif 
}
}

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.