# 新騎資訊面試題目 [toc] ## Q1:簡單 JOIN ### 資料表格式說明 - 會員資料表 [Member]: - Id:`PRIMARY KEY` - Account:會員帳號 - 會員詳細資料資料表 [MemberDetail]: - Id:`PRIMARY KEY` - MemberId:`[Member]` 的 Id - Name:真實姓名 - PhoneNumber:電話號碼 ### 資料表內容: `[Member]` | Id | Account | | ---- | ---- | | 1 | jack1234 | | 2 | mark5678 | | 3 | tom5566 | `[MemberDetail]` | Id | MemberId | Name | PhoneNumber | | ---- | ---- | ---- | ---- | | 1 | 1 | Jack | 0912345678 | | 2 | 3 | Tom | 0987654321 | ### 問題: 請寫一段語法,查詢出會員帳號與詳細資訊 需顯示的欄位為: select member.Account, MemberDetail.Name, MemberDetail.PhoneNumber from Member inner join MemberDetail on Member.Id=MemberDetail.MemberId | Account | Name | PhoneNumber | | ---- | ---- | ---- | ## Q2:List 資料更新 ### 問題 請處理以下程式中的 `DeleteMembers`: 將傳入 `DeleteMembers` 中的 `members` 做軟刪除 `※ 註:軟刪除就是將 IsDelete 變為 true` 並將已刪除的 member id 轉為 List 回傳 ```csharp= class Program { static void Main(string[] args) { var members = new List<Member>() { new Member(1, "Jack"), new Member(2, "Mark"), new Member(3, "Tom"), }; var result = DeleteMembers(members); Console.ReadLine(); } /// <summary> /// 刪除會員 /// </summary> /// <param name="members"></param> /// <returns></returns> public static List<int> DeleteMembers(List<Member> members) { List<int> resultIds; // ******** 作答區 ******** // 1. 軟刪除:將 IsDelete 變為 true Member.IsDelete = true // 2. 將已經刪除的會員 id 回傳出來 resultIds = members // *********************** return resultIds; } /// <summary> /// 會員 /// </summary> /// <returns></returns> public class Member { public Member(int id, string name) { Id = id; Name = name; IsDelete = false; } /// <summary> /// 會員 Id /// </summary> public int Id { get; set; } /// <summary> /// 會員名稱 /// </summary> public string Name { get; set; } /// <summary> /// 是否已刪除 /// </summary> public bool IsDelete { get; set; } } } ``` ## Q3. 請回答以下 Console.WriteLine 分別會顯示什麼? ``` C# namespace Util.Test { class Program { static void Main(string[] args) { var Tbank = new TaiwanBankAccount(); var LineBank = new LineBankAccount(); Console.WriteLine($"1.{Tbank.WithdrawMoney()}"); Console.WriteLine($"2.{Tbank.BankCode}"); Console.WriteLine($"3.{LineBank.BankCode}"); Console.WriteLine($"4.{LineBank.GetMoney(1)}"); Console.WriteLine($"5.{LineBank.GetMoney(1, 2)}"); Console.WriteLine($"6.{LineBank.LimitAccount}"); Console.ReadLine(); } } public class BankAccount { private int LimitAccount = 13; public virtual string BankCode => "001"; public virtual string WithdrawMoney() { return ""; } } public class TaiwanBankAccount : BankAccount { public override string WithdrawMoney() { return "Web"; } public override string BankCode => "002"; } public class LineBankAccount : BankAccount { public override string WithdrawMoney() { return "Bank"; } public int GetMoney(int amount) { return amount * 2; } public int GetMoney(int amount, int amount2) { return amount * amount2; } } } ``` Web 002 001 2 2 13 ## 回答方式 請另開一份 hackmd 記錄下題目以及答案 提供給 HR hackmd 的連結以供審查
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up