我想定義寫入的字符。 我認爲通過舉例說明會更容易解釋。字符解釋
樣本;
void Main(){
List<account> account = new List<UserQuery.account>{
new account() { accountCode = "100", accountName = "That is the house which I want. " },
new account() { accountCode = "101", accountName = "I bought whatever you wanted" },
new account() { accountCode = "102", accountName = "The flowers which you brought me were very beautiful."}
};
string search = "*house*";
string search2 = "The flowers*";
string search3 = "*wanted.";
var result = account.FirstOrDefault(a => a.accountName.Contains(search)).accountCode;
var result2 = account.FirstOrDefault(a => a.accountName.StartsWith(search2)).accountCode;
var result3 = account.FirstOrDefault(a => a.accountName.EndsWith(search3)).accountCode;
}
public class account
{
public string accountCode { get; set; }
public string accountName { get; set; }
}
> result=100
result2=102
result3=101
這是我如何搜索明星人物。
你想完全定義什麼? – Isuka
我不明白你的問題要麼 – Pikoh
所以你想使用通配符來搜索,而不是'StartsWith','EndsWith'和'Contains'? – Silvermind