Usage of AS and IS in C #

xiaoxiao2021-03-06  17

I am going online today. I opened MSN and I saw a 9CBS friend sent a deliberation letter. At the same time, he sent a post on 9CBS. The question he asked is the top most basic grammar knowledge. I really don't understand how the programs are not here, I really don't know how he is mixed now.

His question is:

There is such code: GroupRadiobutton selectradioButton = DGItem.FindControl ("SelectradioButton") as groupradiobutton; "as groupradiobutton;" What does it mean to feel VB? I tried I = 10 as int compilation actually there is no mistake

Why do such a code can be compiled. In C #, all things are objects. Therefore, 10 is also an integer object. It used here, what is AS? He told me that you can't find help about AS in MSDN. It is also, you have no AS introduction in the index in the msdn, where is it to find help? In fact, you can just enter the keyword. Find the C # keyword, there is a usage for AS and IS.

The AS operator is similar to type conversion. When the conversion fails, the AS operator will generate empty, not an exception. In form, this form of expression: The Expression As TypeAs operator performs reference conversion and packing conversion. The AS operator cannot perform other transformations, such as user-defined conversions, such conversion should use the CAST expression instead of its execution.

About IS is actually similar, but IS will not help you carry out any conversion. So you need to display your display conversion

The IS operator is used to check if the time type of the object is compatible with a given type.

Then the above expression should be written like this.

IF (10 IS INT)

{

INT i = (int) 10;

}

转载请注明原文地址:https://www.9cbs.com/read-41235.html

New Post(0)