linq中的元素操作符
元素操作符僅返回一個(gè)元素。
一、Fitst操作符
First操作符將返回序列中的第一個(gè)元素。如果序列中不包含任何元素,則First<T>方法將引發(fā)異常。來(lái)看看First()方法的定義:
從定義中可以看出:First()方法共有兩個(gè)重載。First<T>的有參重載方法中可以指定一個(gè)條件,操作將返回序列中滿(mǎn)足此條件的第一個(gè)元素。從查詢(xún)結(jié)果上看,source.First<T>(條件)方法與source.where(條件).First<T>是一樣的,但是需要注意的是:First<T>(條件)操作將返回序列中滿(mǎn)足此條件的第一個(gè)元素,這將會(huì)忽略后面的遍歷操作,效率更高。請(qǐng)看下面的例子:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ElementOperation { class Program { static void Main(string[] args) { // First List<Product> listProduct = new List<Product>() { new Product(){Id=1,CategoryId=1, Name="C#高級(jí)編程第10版", Price=100.67,CreateTime=DateTime.Now}, new Product(){Id=2,CategoryId=1, Name="Redis開(kāi)發(fā)和運(yùn)維", Price=69.9,CreateTime=DateTime.Now.AddDays(-19)}, new Product(){Id=3,CategoryId=2, Name="活著", Price=57,CreateTime=DateTime.Now.AddMonths(-3)}, new Product(){Id=4,CategoryId=3, Name="高等數(shù)學(xué)", Price=97,CreateTime=DateTime.Now.AddMonths(-1)}, new Product(){Id=5,CategoryId=6, Name="國(guó)家寶藏", Price=52.8,CreateTime=DateTime.Now.AddMonths(-1)} }; // 方法語(yǔ)法 var productExp = listProduct.First(); Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}"); // 查詢(xún)表達(dá)式 var productFun = (from p in listProduct select p).First(); Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}"); // 根據(jù)委托進(jìn)行刷選 // 查詢(xún)CategoryId為1的集合的第一個(gè)元素 // 方法語(yǔ)法 var productDeleExp = listProduct.First(p => p.CategoryId.Equals(1)); Console.WriteLine($"Id:{productDeleExp.Id},CategoryId:{productDeleExp.CategoryId},Name:{productDeleExp.Name},Price:{productDeleExp.Price},CreateTime:{productDeleExp.CreateTime}"); // 查詢(xún)表達(dá)式 var productDeleFun = (from p in listProduct where p.CategoryId.Equals(1) select p).First(); Console.WriteLine($"Id:{productDeleFun.Id},CategoryId:{productDeleFun.CategoryId},Name:{productDeleFun.Name},Price:{productDeleFun.Price},CreateTime:{productDeleFun.CreateTime}"); // 或者使用下面的查詢(xún)表達(dá)式 var product = (from p in listProduct select p).First(z => z.CategoryId.Equals(1)); Console.WriteLine($"Id:{product.Id},CategoryId:{product.CategoryId},Name:{product.Name},Price:{product.Price},CreateTime:{product.CreateTime}"); Console.ReadKey(); } } }
結(jié)果:
注意:
- 如果序列中不包含任何元素,則First<T>方法將引發(fā)異常。
看下面的例子:
var pro = listProduct.First(p => p.CategoryId.Equals(4)); Console.WriteLine($"Id:{pro.Id},CategoryId:{pro.CategoryId},Name:{pro.Name},Price:{pro.Price},CreateTime:{pro.CreateTime}");
結(jié)果:
二、FirstOrDefault操作符
FirstOrDefault操作符也是返回序列中的第一個(gè)元素。與First()操作符不同的是:如果序列中不包含任何元素,F(xiàn)irstOrDefault則返回默認(rèn)值,程序不會(huì)報(bào)錯(cuò)。來(lái)看看定義:
從定義中可以看出:FirstOrDefault和First操作符的重載方法一致。請(qǐng)看下面的例子:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ElementOperation { class Program { static void Main(string[] args) { // First List<Product> listProduct = new List<Product>() { new Product(){Id=1,CategoryId=1, Name="C#高級(jí)編程第10版", Price=100.67,CreateTime=DateTime.Now}, new Product(){Id=2,CategoryId=1, Name="Redis開(kāi)發(fā)和運(yùn)維", Price=69.9,CreateTime=DateTime.Now.AddDays(-19)}, new Product(){Id=3,CategoryId=2, Name="活著", Price=57,CreateTime=DateTime.Now.AddMonths(-3)}, new Product(){Id=4,CategoryId=3, Name="高等數(shù)學(xué)", Price=97,CreateTime=DateTime.Now.AddMonths(-1)}, new Product(){Id=5,CategoryId=6, Name="國(guó)家寶藏", Price=52.8,CreateTime=DateTime.Now.AddMonths(-1)} }; // 方法語(yǔ)法 var productExp = listProduct.FirstOrDefault(); Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}"); // 查詢(xún)表達(dá)式 var productFun = (from p in listProduct select p).FirstOrDefault(); Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}"); // 根據(jù)委托進(jìn)行刷選 // 查詢(xún)CategoryId為1的集合的第一個(gè)元素 // 方法語(yǔ)法 var productDeleExp = listProduct.FirstOrDefault(p => p.CategoryId.Equals(1)); Console.WriteLine($"Id:{productDeleExp.Id},CategoryId:{productDeleExp.CategoryId},Name:{productDeleExp.Name},Price:{productDeleExp.Price},CreateTime:{productDeleExp.CreateTime}"); // 查詢(xún)表達(dá)式 var productDeleFun = (from p in listProduct where p.CategoryId.Equals(1) select p).FirstOrDefault(); Console.WriteLine($"Id:{productDeleFun.Id},CategoryId:{productDeleFun.CategoryId},Name:{productDeleFun.Name},Price:{productDeleFun.Price},CreateTime:{productDeleFun.CreateTime}"); // 或者使用下面的查詢(xún)表達(dá)式 var product = (from p in listProduct select p).FirstOrDefault(z => z.CategoryId.Equals(1)); Console.WriteLine($"Id:{product.Id},CategoryId:{product.CategoryId},Name:{product.Name},Price:{product.Price},CreateTime:{product.CreateTime}"); Console.ReadKey(); } } }
結(jié)果:
注意:
與First()操作符不同的是:如果序列中不包含任何元素,F(xiàn)irstOrDefault則返回默認(rèn)值,程序不會(huì)報(bào)錯(cuò)。看下面的例子:
// 查詢(xún)listProduct中CategoryId為4的集合的第一個(gè)元素 var pro = listProduct.FirstOrDefault(p => p.CategoryId.Equals(4)); Console.WriteLine($"Id:{pro.Id},CategoryId:{pro.CategoryId},Name:{pro.Name},Price:{pro.Price},CreateTime:{pro.CreateTime}");
結(jié)果:
從上面的截圖中看出:如果序列中不包含任何元素,會(huì)自動(dòng)用null進(jìn)行填充。但是下面輸出的時(shí)候要先判斷查詢(xún)結(jié)果是否為null。
三、Last操作符
Last方法將返回序列中的最后一個(gè)元素??聪旅娴睦樱?/p>
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ElementOperation { class Program { static void Main(string[] args) { // First List<Product> listProduct = new List<Product>() { new Product(){Id=1,CategoryId=1, Name="C#高級(jí)編程第10版", Price=100.67,CreateTime=DateTime.Now}, new Product(){Id=2,CategoryId=1, Name="Redis開(kāi)發(fā)和運(yùn)維", Price=69.9,CreateTime=DateTime.Now.AddDays(-19)}, new Product(){Id=3,CategoryId=2, Name="活著", Price=57,CreateTime=DateTime.Now.AddMonths(-3)}, new Product(){Id=4,CategoryId=3, Name="高等數(shù)學(xué)", Price=97,CreateTime=DateTime.Now.AddMonths(-1)}, new Product(){Id=5,CategoryId=6, Name="國(guó)家寶藏", Price=52.8,CreateTime=DateTime.Now.AddMonths(-1)} }; // 方法語(yǔ)法 var productExp = listProduct.Last(); Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}"); // 查詢(xún)表達(dá)式 var productFun = (from p in listProduct select p).Last(); Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}"); // 根據(jù)委托進(jìn)行刷選 // 查詢(xún)CategoryId為1的集合的第一個(gè)元素 // 方法語(yǔ)法 var productDeleExp = listProduct.Last(p => p.CategoryId.Equals(1)); Console.WriteLine($"Id:{productDeleExp.Id},CategoryId:{productDeleExp.CategoryId},Name:{productDeleExp.Name},Price:{productDeleExp.Price},CreateTime:{productDeleExp.CreateTime}"); // 查詢(xún)表達(dá)式 var productDeleFun = (from p in listProduct where p.CategoryId.Equals(1) select p).Last(); Console.WriteLine($"Id:{productDeleFun.Id},CategoryId:{productDeleFun.CategoryId},Name:{productDeleFun.Name},Price:{productDeleFun.Price},CreateTime:{productDeleFun.CreateTime}"); // 或者使用下面的查詢(xún)表達(dá)式 var product = (from p in listProduct select p).Last(z => z.CategoryId.Equals(1)); Console.WriteLine($"Id:{product.Id},CategoryId:{product.CategoryId},Name:{product.Name},Price:{product.Price},CreateTime:{product.CreateTime}"); Console.ReadKey(); } } }
結(jié)果:
注意:
Last操作符和First操作符一樣,如果序列中不包含任何元素,則程序會(huì)直接報(bào)錯(cuò)。
四、LastOrDefault操作符
LastOrDefault操作符將返回序列中的最后一個(gè)元素;如果序列中不包含任何元素,則返回默認(rèn)值。來(lái)看下面的例子:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ElementOperation { class Program { static void Main(string[] args) { // First List<Product> listProduct = new List<Product>() { new Product(){Id=1,CategoryId=1, Name="C#高級(jí)編程第10版", Price=100.67,CreateTime=DateTime.Now}, new Product(){Id=2,CategoryId=1, Name="Redis開(kāi)發(fā)和運(yùn)維", Price=69.9,CreateTime=DateTime.Now.AddDays(-19)}, new Product(){Id=3,CategoryId=2, Name="活著", Price=57,CreateTime=DateTime.Now.AddMonths(-3)}, new Product(){Id=4,CategoryId=3, Name="高等數(shù)學(xué)", Price=97,CreateTime=DateTime.Now.AddMonths(-1)}, new Product(){Id=5,CategoryId=6, Name="國(guó)家寶藏", Price=52.8,CreateTime=DateTime.Now.AddMonths(-1)} }; // 方法語(yǔ)法 var productExp = listProduct.LastOrDefault(); Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}"); // 查詢(xún)表達(dá)式 var productFun = (from p in listProduct select p).LastOrDefault(); Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}"); // 根據(jù)委托進(jìn)行刷選 // 查詢(xún)CategoryId為1的集合的第一個(gè)元素 // 方法語(yǔ)法 var productDeleExp = listProduct.LastOrDefault(p => p.CategoryId.Equals(1)); Console.WriteLine($"Id:{productDeleExp.Id},CategoryId:{productDeleExp.CategoryId},Name:{productDeleExp.Name},Price:{productDeleExp.Price},CreateTime:{productDeleExp.CreateTime}"); // 查詢(xún)表達(dá)式 var productDeleFun = (from p in listProduct where p.CategoryId.Equals(1) select p).LastOrDefault(); Console.WriteLine($"Id:{productDeleFun.Id},CategoryId:{productDeleFun.CategoryId},Name:{productDeleFun.Name},Price:{productDeleFun.Price},CreateTime:{productDeleFun.CreateTime}"); // 或者使用下面的查詢(xún)表達(dá)式 var product = (from p in listProduct select p).LastOrDefault(z => z.CategoryId.Equals(1)); Console.WriteLine($"Id:{product.Id},CategoryId:{product.CategoryId},Name:{product.Name},Price:{product.Price},CreateTime:{product.CreateTime}"); Console.ReadKey(); } } }
結(jié)果:
注意:
LastOrDefault和FirstOrDefault一樣,如果序列中不包含任何元素,則使用null值進(jìn)行填充返回值。
五、ElementAt操作符
ElementAt操作符返回序列中指定索引處的元素。來(lái)看下面的例子:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ElementOperation { class Program { static void Main(string[] args) { // First List<Product> listProduct = new List<Product>() { new Product(){Id=1,CategoryId=1, Name="C#高級(jí)編程第10版", Price=100.67,CreateTime=DateTime.Now}, new Product(){Id=2,CategoryId=1, Name="Redis開(kāi)發(fā)和運(yùn)維", Price=69.9,CreateTime=DateTime.Now.AddDays(-19)}, new Product(){Id=3,CategoryId=2, Name="活著", Price=57,CreateTime=DateTime.Now.AddMonths(-3)}, new Product(){Id=4,CategoryId=3, Name="高等數(shù)學(xué)", Price=97,CreateTime=DateTime.Now.AddMonths(-1)}, new Product(){Id=5,CategoryId=6, Name="國(guó)家寶藏", Price=52.8,CreateTime=DateTime.Now.AddMonths(-1)} }; // 方法語(yǔ)法 // 查詢(xún)集合中索引為3的元素 即Id=4 var productExp = listProduct.ElementAt(3); Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}"); // 查詢(xún)表達(dá)式 // 查詢(xún)集合中索引為2的元素 即Id=3 var productFun = (from p in listProduct select p).ElementAt(2); Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}"); Console.ReadKey(); } } }
結(jié)果:
注意:
ElementAt()的參數(shù)值必須是集合中存在的索引,否則程序會(huì)直接報(bào)錯(cuò),看下面的例子:
// 查詢(xún)集合中索引為7的元素 var product = listProduct.ElementAt(7);
結(jié)果:
六:ElementAtOrDefault操作符
ElementAtOrDefault方法將返回序列中指定索引處的元素;如果索引超出范圍,則返回默認(rèn)值??聪旅娴睦樱?/p>
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ElementOperation { class Program { static void Main(string[] args) { // First List<Product> listProduct = new List<Product>() { new Product(){Id=1,CategoryId=1, Name="C#高級(jí)編程第10版", Price=100.67,CreateTime=DateTime.Now}, new Product(){Id=2,CategoryId=1, Name="Redis開(kāi)發(fā)和運(yùn)維", Price=69.9,CreateTime=DateTime.Now.AddDays(-19)}, new Product(){Id=3,CategoryId=2, Name="活著", Price=57,CreateTime=DateTime.Now.AddMonths(-3)}, new Product(){Id=4,CategoryId=3, Name="高等數(shù)學(xué)", Price=97,CreateTime=DateTime.Now.AddMonths(-1)}, new Product(){Id=5,CategoryId=6, Name="國(guó)家寶藏", Price=52.8,CreateTime=DateTime.Now.AddMonths(-1)} }; // 方法語(yǔ)法 // 查詢(xún)集合中索引為3的元素 即Id=4 var productExp = listProduct.ElementAtOrDefault(3); Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}"); // 查詢(xún)表達(dá)式 // 查詢(xún)集合中索引為2的元素 即Id=3 var productFun = (from p in listProduct select p).ElementAtOrDefault(2); Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}"); Console.ReadKey(); } } }
結(jié)果:
注意:
如果索引超出范圍,則返回默認(rèn)值??聪旅娴睦樱?/p>
從上面的截圖中看出:如果索引超出范圍,則用null填充返回值。
七、Single操作符
Single操作符將從一個(gè)序列中返回單個(gè)元素,如果該序列包含多個(gè)元素,或者沒(méi)有元素?cái)?shù)為0,則會(huì)引發(fā)異常。看看定義:
從定義中能夠看出:Single操作符共有兩個(gè)重載的方法。無(wú)參的方法重載將從一個(gè)序列中返回單個(gè)元素,如果該序列包含多個(gè)元素,或者沒(méi)有元素?cái)?shù)為0,則會(huì)引發(fā)異常。參數(shù)為委托的方法重載將返回滿(mǎn)足委托條件的單個(gè)元素??聪旅娴睦樱?/p>
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ElementOperation { class Program { static void Main(string[] args) { List<Product> listProduct = new List<Product>() { new Product(){Id=1,CategoryId=1, Name="C#高級(jí)編程第10版", Price=100.67,CreateTime=DateTime.Now} }; // 方法語(yǔ)法 var productExp = listProduct.Single(); Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}"); // 查詢(xún)表達(dá)式 var productFun = (from p in listProduct select p).Single(); Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}"); // 根據(jù)委托進(jìn)行刷選 // 查詢(xún)CategoryId為1的集合的第一個(gè)元素 // 方法語(yǔ)法 var productDeleExp = listProduct.Single(p => p.CategoryId.Equals(1)); Console.WriteLine($"Id:{productDeleExp.Id},CategoryId:{productDeleExp.CategoryId},Name:{productDeleExp.Name},Price:{productDeleExp.Price},CreateTime:{productDeleExp.CreateTime}"); // 查詢(xún)表達(dá)式 var productDeleFun = (from p in listProduct where p.CategoryId.Equals(1) select p).Single(); Console.WriteLine($"Id:{productDeleFun.Id},CategoryId:{productDeleFun.CategoryId},Name:{productDeleFun.Name},Price:{productDeleFun.Price},CreateTime:{productDeleFun.CreateTime}"); // 或者使用下面的查詢(xún)表達(dá)式 var product = (from p in listProduct select p).Single(z => z.CategoryId.Equals(1)); Console.WriteLine($"Id:{product.Id},CategoryId:{product.CategoryId},Name:{product.Name},Price:{product.Price},CreateTime:{product.CreateTime}"); Console.ReadKey(); } } }
結(jié)果:
注意:
如果序列包含多個(gè)元素,或者序列元素?cái)?shù)為0,則會(huì)引發(fā)異常??聪旅娴睦印?/p>
1、序列包含多個(gè)元素
修改ListProduct為包含多個(gè)元素的集合:
// 1、序列包含多個(gè)元素 List<Product> listProduct = new List<Product>() { new Product(){Id=1,CategoryId=1, Name="C#高級(jí)編程第10版", Price=100.67,CreateTime=DateTime.Now}, new Product(){Id=2,CategoryId=1, Name="Redis開(kāi)發(fā)和運(yùn)維", Price=69.9,CreateTime=DateTime.Now.AddDays(-19)}, }; var productExp = listProduct.Single();
結(jié)果:
2、序列中不包含任何元素。
// 2、序列不包含任何元素 List<Product> listProduct = new List<Product>(); var productExp = listProduct.Single();
結(jié)果:
八、SingleOrDefault操作符
SingleOrDefault方操作符將從一個(gè)序列中返回單個(gè)元素。如果元素?cái)?shù)為0,則返回默認(rèn)值??炊x:
從定義中可以看出:SingleOrDefault的定義和Single的定義一致??聪旅娴睦樱?/p>
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ElementOperation { class Program { static void Main(string[] args) { List<Product> listProduct = new List<Product>() { new Product(){Id=1,CategoryId=1, Name="C#高級(jí)編程第10版", Price=100.67,CreateTime=DateTime.Now} }; // 方法語(yǔ)法 var productExp = listProduct.SingleOrDefault(); Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}"); // 查詢(xún)表達(dá)式 var productFun = (from p in listProduct select p).Single(); Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}"); // 根據(jù)委托進(jìn)行刷選 // 查詢(xún)CategoryId為1的集合的第一個(gè)元素 // 方法語(yǔ)法 var productDeleExp = listProduct.Single(p => p.CategoryId.Equals(1)); Console.WriteLine($"Id:{productDeleExp.Id},CategoryId:{productDeleExp.CategoryId},Name:{productDeleExp.Name},Price:{productDeleExp.Price},CreateTime:{productDeleExp.CreateTime}"); // 查詢(xún)表達(dá)式 var productDeleFun = (from p in listProduct where p.CategoryId.Equals(1) select p).Single(); Console.WriteLine($"Id:{productDeleFun.Id},CategoryId:{productDeleFun.CategoryId},Name:{productDeleFun.Name},Price:{productDeleFun.Price},CreateTime:{productDeleFun.CreateTime}"); // 或者使用下面的查詢(xún)表達(dá)式 var product = (from p in listProduct select p).Single(z => z.CategoryId.Equals(1)); Console.WriteLine($"Id:{product.Id},CategoryId:{product.CategoryId},Name:{product.Name},Price:{product.Price},CreateTime:{product.CreateTime}"); Console.ReadKey(); } } }
結(jié)果:
注意:
如果序列包含多個(gè)元素或者不包含任何元素,則用null值填充返回值??聪旅胬樱?/p>
1、序列包含多個(gè)元素
// 1、序列包含多個(gè)元素 List<Product> listProduct = new List<Product>() { new Product(){Id=1,CategoryId=1, Name="C#高級(jí)編程第10版", Price=100.67,CreateTime=DateTime.Now}, new Product(){Id=2,CategoryId=1, Name="Redis開(kāi)發(fā)和運(yùn)維", Price=69.9,CreateTime=DateTime.Now.AddDays(-19)}, }; var productExp = listProduct.SingleOrDefault();
結(jié)果:
2、序列不包含任何元素
// 2、序列不包含任何元素 List<Product> listProduct = new List<Product>(); var productExp = listProduct.SingleOrDefault();
結(jié)果:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
ASP.NET的適配器設(shè)計(jì)模式(Adapter)應(yīng)用詳解
有關(guān)設(shè)計(jì)模式的適配器模式(Adapter)確實(shí)不是很好理解理解,接下來(lái)將做一個(gè)簡(jiǎn)單的例子簡(jiǎn)要說(shuō)明下,感興趣的朋友可不要錯(cuò)過(guò)了哈,希望本文可以幫助到你更好的理解適配器設(shè)計(jì)模式2013-02-02Web API身份認(rèn)證解決方案之Basic基礎(chǔ)認(rèn)證
本文詳細(xì)講解了Web API身份認(rèn)證解決方案之Basic基礎(chǔ)認(rèn)證,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-03-03ASP.NET Core MVC學(xué)習(xí)之視圖組件(View Component)
這篇文章主要給大家介紹了關(guān)于ASP.NET Core MVC學(xué)習(xí)之視圖組件(View Component)的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用ASP.NET Core MVC具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-08-08asp.net中一款極為簡(jiǎn)單實(shí)用的圖表插件(jquery)
這里介紹一款簡(jiǎn)單實(shí)用的圖表插件,該圖表插件是基于jquery和jquery的插件 gchart很容易實(shí)現(xiàn)的,而gchart插件是封裝了google的圖表api 。2011-07-07Asp.Net Core使用SignalR進(jìn)行服務(wù)間調(diào)用方法示例
這篇文章主要介紹了Asp.Net Core使用SignalR進(jìn)行服務(wù)間調(diào)用方法示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-12-12讀寫(xiě)xml所有節(jié)點(diǎn)個(gè)人小結(jié) 和 讀取xml節(jié)點(diǎn)的數(shù)據(jù)總結(jié)
讀寫(xiě)xml所有節(jié)點(diǎn)個(gè)人小結(jié) 和 讀取xml節(jié)點(diǎn)的數(shù)據(jù)總結(jié)...2007-03-03