4月文思創新筆試題(c#/sql)整理稿!

1、關於構造函數與靜態構造函數的題,很簡單.

2、關於繼承、多態的考察,也很簡單。

3、根據委託(delegate)的知識,請完成以下用戶控件中代碼片段的填寫

namespace test
{
public delegate void OnDBOperate();
public class UserControlBase : System.Windows.Forms.UserControl
{
public event OnDBOperate OnNew;
private void toolBar_ButtonClick(objectsender,System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
if(e.Button.Equals(BtnNew))
{
//請在以下補齊代碼用來調用OnDBOperate委託簽名的OnNew事件。
}
}
}
答:if( OnNew != null )
OnNew( this, e );

4、
public static void test(string  ConnectString)
{
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
conn.ConnectionString = ConnectString;
try
{
conn.Open();
…….
}catch(Exception Ex)
{
MessageBox.Show(Ex.ToString());
}finally
{
if (!conn.State.Equals(ConnectionState.Closed))
conn.Close();
}
請問
1)以上代碼可以正確使用連接池嗎?
2)以上代碼所使用的異常處理方法,是否所有在test方法內的異常都可以被捕捉並顯示出來?

5、問題:Can you use a SQL statement to calculating it!
How can I print "10 to 20" for books that sell for between $10 and $20,"unknown" for books whose price is null, and "other" for all other prices?
答案:
select bookid,bookname,price=case when price is null then 'unknown'
       when  price between 10 and 20 then '10 to 20' else price end
from books

6、SQLSERVER服務器中,給定表 table1 中有兩個字段 ID、LastUpdateDate,ID表示更新的事務號, LastUpdateDate表示更新時的服務器時間,請使用一句SQL語句獲得最後更新的事務號。(10)
答:Select ID FROM table1
Where LastUpdateDate = (Select MAX(LastUpdateDate) FROM table1)

7、
題目大意是編寫代碼,功能是C#實現字符串的如下效果:
輸入:"All-In-Love",輸出:"All-In-Love"
輸入:"All In Love",輸出:"Love In All"
輸入:"Hello,the world!",輸出:"!world the,Hello"

8、數據庫操作的考察,比較麻煩。

 

 


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章