Common interview with C # technical topics

Source: Internet
Author: User

Null textbox for Traverse query form interface

?
foreach (System.Windows.Forms.Control control in this.Controls)           {               if (control is TextBox)               {                   TextBox tx = (TextBox)control;                   tx.Text = string.Empty;               }           }

  

?
一列数的规则如下: 1、1、2、3、5、8、13、21、34......  求第30位数是多少, 用递归算法实现。答:public class MainClass              public static void Main()                        Console.WriteLine(Foo(30));                  public static int Foo(int i)                      if (i <= 0)                  return 0;              else if(i > 0 && i <= 2)                  return 1;              else return Foo(i -1) + Foo(i - 2);             

  The classics are bubbling again.

请编程实现一个冒泡排序算法? 答:         int [] array = new int [*] ; int temp = 0 ; for (int i = 0 ; i < array.Length - 1 ; i++) { for (int j = i + 1 ; j < array.Length ; j++) { if (array[j] < array[i]) { temp = array[i] ; array[i] = array[j] ; array[j] = temp ; } } }

  

?
求以下表达式的值,写出您想到的一种或几种实现方法: 1-2+3-4+……+m 答:     int Num = this.TextBox1.Text.ToString() ; int Sum = 0 ; for (int i = 0 ; i < Num + 1 ; i++) { if((i%2) == 1) { Sum += i ; } else{ Sum = Sum  - I ; } } System.Console.WriteLine(Sum.ToString()); System.Console.ReadLine() ;

  

Common interview with C # technical topics

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.