List C # interview questions

Source: Internet
Author: User

Q & A follows

S1 C #:

Labels:

1. = what is the difference between Equals and Equals?

For Value Type: Because the value type is stored in the stack, both of them compare whether the values of two variables in the stack are equal.

For reference type: the reference type is a storage reference in the heap, pointing to a specific value in the heap. = Judge the reference address, equals judgment Value

2. Differences between switches in Java and switches in C #

Switch in Java: Only int, short, and type smaller than int

Switch in C #: it can be used to determine the string type and the type that occupies less bytes than the string type.

Ch2:

1. bubble sort (c #) Tips

Int [] numbers = {49, 12, 65, 45, 88, 54 };

// Before sorting

Console. WriteLine ("Before sorting :");

Foreach (int I in numbers)

{

Console. Write (I + "");

}

// Bubble sort

For (int I = 0; I <numbers. Length; I ++)

{

For (int j = 0; j <numbers. Length-1-I; j ++)

{// Swap the maximum number to the end

If (numbers [j]> numbers [j + 1])

{

Int temp = numbers [j];

Numbers [j] = numbers [j + 1];

Numbers [j + 1] = temp;

}

}

}

// After sorting

Console. WriteLine ("sorted :");

Foreach (int I in numbers)

{

Console. Write (I + "");

}

2. write four types of loop syntax

For (int I = 0; I <length; I ++) {} while (true) {} foreach (int I in numbers) {} do {} while (true );

3. Calculate the maximum number in the array, print all the daffodils, and print the 9-9 multiplication table.

Calculate the maximum number: int [] numbers = {49, 12, 65, 45, 88, 54 };

Int max = 0;

For (int I = 0; I <numbers. Length-1; I ++)

{

If (numbers [I]> numbers [I + 1])

{

Max = numbers [I];

}

}

Console. WriteLine ("max:" + max );

Daffodils: for (int I = 100; I <1000; I ++)

{

Int a = I % 10; // single digit

Int B = I % 100; // ten digits

B = B/10;

Int c = I/100; // hundreds of digits

Int number = (int) Math. Pow (a, 3) + (int) Math. Pow (B, 3) + (int) Math. Pow (c, 3 );

If (number = I)

{

Console. Write (I + "");

}

}

Print the 9-9 multiplication table: for (int I = 1; I <= 9; I ++)

{

For (int j = 1; j <= I; j ++)

{

Console. Write ("{0} × {1} = {2}", j, I, I * j );

}

Console. WriteLine ();

}

Ch3:

1. namespace meaning: Package for ease of Management

2. The difference between the transfer of reference and value: it is mainly relative to the value type. You can use the transfer of reference and ref to truly change the value. Value transfer. The value will not be changed after the method is called.

3. write out the common methods of String (10) and describe the function.

Equals (): equal judgment value Split ():... Split each character into string [] array IndexOf (): returns the index of the specified character

Concat (): connection, equivalent to '+' Trim (): Ignore front and rear spaces ToUpper (): Convert to uppercase &

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.