最全面Enumerable类的实用总结

简介: 最全面Enumerable类的实用总结

ALL方法判断序列元素是否满足条件,如果满足条件则返回true’;否则返回false,该方法语法如下:

public static bool All<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate);


   参数:


    Source:包含要应用谓词的元素的 System.Collections.Generic.IEnumerable<T>。


    predicate:     用于测试每个元素是否满足条件的函数。


类型参数:  TSource: source 中的元素的类型。


      返回结果: 如果源序列中的每个元素都通过指定谓词中的测试,或者序列为空,则为 true;否则为 false。


public partial class Frm_Main : Form


   {

       public Frm_Main()


       {

           InitializeComponent();


       }


       private void Frm_Main_Load(object sender, EventArgs e)


       {

           List<Person> People = new List<Person>//创建人员列表


       {

           new Person(1,"王*军",28),


           new Person(2,"赵*东",31),


           new Person(3,"王*科",33)


       };


           bool result = People.All(p => p.Old > 30);//判断是否所有人员的年龄都大于30岁


           label3.Text = "查询结果:" + result.ToString();//查询结果


       }



输出结果:false


   }



   public class Person


   {

       public Person(int id, string name, int old)


       {

           this.ID = id;


           this.Name = name;


           this.Old = old;


       }


       public int ID { get; set; }//人员ID


       public string Name { get; set; }//人员名称


       public int Old { get; set; }//年龄


   }


使用Count也可以实现相同的功能:


bool result=People.Count(p=>p.Old>=30)==People.Count();


使用ElementAt方法获取指定位置的元素,语法:

public static TSource ElementAt<TSource>(this IEnumerable<TSource> source, int index);


参数:


 source: 要从中返回元素的 System.Collections.Generic.IEnumerable<T>。


index:  要检索的从零开始的元素索引。


类型参数:  TSource: source 中的元素的类型。


返回结果:  源序列中指定位置处的元素。


例:List<int> ints=new List<int>({0,1,2,3,4,5,6}); int result=ints.ElementAt(3);


Repeat方法用来生成一个重复值的序列

语法格式:


public static IEnumerable<TResult> Repeat<TResult>(TResult element, int count);


element:要重复的值。Count:在生成序列中重复该值的次数。


返回值:一个IEnumerable<T>:包含一个重复值。


例:string[] strA=Enumerable.Repeat<String>(“lsj”,3).ToArray();//初始化长度为3的字符串数组,所有的元素之为”lsj”


Range方法:Enumerable类的Range方法用来生成指定范围的整数序列,语法格式:

 public static IEnumerable<int> Range(int start, int count);


start:序列中一个整数的值。Count:要生成的顺序整数的数组。


返回值:IEnumerable<Int32>数型值。


例:int[] intA=Enumerable.Range(0,3).ToArray<int>();//长度为3,元素值:0,1,2


int[] intB=Enumerable.Range(0,5).Select(i=>i*10).ToArray<int>();//元素值为:0,10,20,30,40


ConCat方法:用来连接两个序列,语法如下:  public static IEnumerable<TSource> Concat<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second);

参数说明:first:要连接的一个序列,second:要与一个序列连接的序列。


返回值:一个IEnumerable<T>,包含两个输入序列的连接元素。


例:string[] str3=str1.Concat(str2);


OfType方法:用来根据指定类型筛选序列中的元素,语法如下:

public static IEnumerable<TResult> OfType<TResult>(this IEnumerable source);


参数说明:TResult筛选序列元素所指定的类型。Source:IEnumerable类型的源序列。返回值:只返回元素是TResult类型的序列。


例:ArrayList arr=new ArrayList(); arrList.Add(1);arrList.Add(2);arrList.Add(3);arrList.Add(“A”);arrList.Add(“b”);


     var query=from item in arrList.OfType<string>() select item;


      结果:A b


Jion方法:用来基于匹配键对两个序列的元素进行关联,使用默认的相等比较器对键进行比较,其语法如下:  public static IEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector);

参数:


          outer:要联接的第一个序列。


 inner:要与第一个序列联接的序列。


          outerKeySelector: 用于从第一个序列的每个元素提取联接键的函数。innerKeySelector:用于从第二个序列的每个元素提取联接键的函数。


resultSelector:用于从两个匹配元素创建结果元素的函数。


       类型参数:  TOuter:   第一个序列中的元素的类型。


 TInner: 第二个序列中的元素的类型。


  TKey:   键选择器函数返回的键的类型。


  TResult:  结果元素的类型。


       返回结果:  一个具有 TResult 类型元素的 System.Collections.Generic.IEnumerable<T>,这些元素是通过对两个序列执行内部联接得来的。


例:public partial class Frm_Main : Form


   {

       public Frm_Main()


       {

           InitializeComponent();


       }


       private void Frm_Main_Load(object sender, EventArgs e)


       {

           List<SaleBill> bills = new List<SaleBill>//创建销售单列表


       {

           new SaleBill("XS001","王*科",Convert.ToDateTime("2010-1-1")),


           new SaleBill("XS002","王*军",Convert.ToDateTime("2010-2-1")),


           new SaleBill("XS003","赵*东",Convert.ToDateTime("2010-3-1"))


       };


           List<SaleProduct> products = new List<SaleProduct>//创建销售商品列表


       {

           new SaleProduct("XS001","冰箱",1,2000),


           new SaleProduct("XS001","洗衣机",2,600),


           new SaleProduct("XS002","电暖风",3,50),


           new SaleProduct("XS002","吸尘器",4,200),


           new SaleProduct("XS003","手机",1,990)


       };


           //关联销售单列表和销售商品列表      


           var query= bills.Join(products,


                              b => b.SaleBillCode,


                              p => p.SaleBillCode,


                              (b, p) => new


                              {

                                  销售单号 = b.SaleBillCode,


                                  销售日期 = b.SaleDate,


                                  销售员 = b.SaleMan,


                                  商品名称 = p.ProductName,


                                  数量 = p.Quantity,


                                  单价 = p.Price,


                                  金额 = p.Quantity * p.Price


                              });


           dataGridView1.DataSource = query.ToList();//数据绑定


       }


   }


   class SaleBill//销售单据类


   {

       public SaleBill(string saleBillCode, string saleMan, DateTime saleDate)


       {

           this.SaleBillCode = saleBillCode;


           this.SaleMan = saleMan;


           this.SaleDate = saleDate;


       }


       public string SaleBillCode { get; set; }//销售单号


       public string SaleMan { get; set; }//销售员


       public DateTime SaleDate { get; set; }//销售日期


   }


   class SaleProduct//销售商品类


   {

       public SaleProduct(string saleBillCode, string productName, int quantity, double price)


       {

           this.SaleBillCode = saleBillCode;


           this.ProductName = productName;


           this.Quantity = quantity;


           this.Price = price;


       }


       public string SaleBillCode { get; set; }//销售单号


       public string ProductName { get; set; }//商品名称


       public int Quantity { get; set; }//数量


       public double Price { get; set; }//单价


}


输出结果:

tt.png

IsUpper方法用来指定的Unicode字符是否属于大写字母类别,语法如下:

public static bool IsUpper(char c)


c:System.Char类型,一个Unicode字符。


返回值:如果c是大写字母,则为true,否则为false。


例:var query=from s in sourceString where char.IsUpper(s) select s;


IsLetter方法可以过滤字符串中属于字母类别的字符,例:

var query=from s in sourceString where char.IsLetter(s) select s;


IsDigit方法用来指示字符串是否属于十进制数字类别。

Var query=from s in sourceString where char.IsDigit(s) select s;


IsControl方法可以过滤字符串中的控制字符串,例:

Var query =from s in sourceString where char.IsControl(s) select s;


IsLower方法可以过滤字符串中属于小写字母的名称,例:

 Var query=from s in sourceString where char.IsLower(s) select s;


Aggregate方法用来堆积和中的元素进行自定义的聚合计算,其语法格式如下:

public static TResult Aggregate<TSource, TAccumulate, TResult>(this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector);


参数:


TSource: source 中的元素的类型。


source:IEnumerable<TSource>类型。


func:System.Func<TSource,TSource,TSource>类型,拜师对每个元素调用的累加器函数。


返回值:TSource 类型,累加器的最终值。


例:


     DataClassesDataContext dc = new DataClassesDataContext();//创建LINQ对象


           //将销售商品明细表中的金额字段值取出,并转换为数组


           double[] amountArray = dc.V_SaleDetail.Select(itm => itm.amount).ToArray<double>();


           double amountSum = amountArray.Aggregate((a, b) => a + b);//计算商品销售总额


//等效于:  double amountSum = amountArray.Sum();


AsEnumerable方法,用来将数据源转换为IEnumerable<T>类型,语法如下:

public static IEnumerable<TSource> AsEnumerable<TSource>(this IEnumerable<TSource> source);


参数说明:TSource:source中的元素的类型。


source:类型为IEnumerable<TSource>的数据源。


返回值:返回类型为IEnumerable<TSource>的序列。


 List<Person> People = new List<Person>();//创建List泛型对象


           for (int i = 1; i < 10; i++)


           {

               People.Add(new Person(i, "User0" + i.ToString()));//添加项


           }


   var query = from p in People.AsEnumerable<Person>()//转换为IEnumerable<Person>类型


                       where p.ID < 4


                       select new


                       {

                           ID = p.ID,


                           Name = p.Name


                       };


           foreach (var item in query)


           {

               label1.Text += item + "\n";//显示信息


           }



注:将List对象转换为T[]类型,代码如下:Person[] perArr=People.ToArray();


将List转换为字典类型:Dictionary<int,Person> dict=People.ToDictionary(item=>item.ID);


ToList方法:用来产品卖给IEnumerable<TSource>类型的实例对象创建一个List<TSource>类型的对象,其语法格式如下:public static List<TSource> ToList<TSource>(this IEnumerable<TSource> source);

参数:


TSource:source中的元素的类型


Source:IEnumerable<TSource>类型的实例对象。


返回值:创建的List<T>类型的对象。


例:


  //构造List<UserInfo>泛型列表


           List<UserInfo> users = new List<UserInfo> {

           new UserInfo{UserCode=1, UserName="User001", Password="001"},


           new UserInfo{UserCode=2, UserName="User002", Password="002"},


           new UserInfo{UserCode=3, UserName="User003", Password="003"},


           new UserInfo{UserCode=4, UserName="User004", Password="004"}};


           //使用LINQ查询用户名等于User001或密码等于003的列表项


           //此时的query变量的类型是IEnumerable<UserInfo>类型


           var query = from item in users


                       where item.UserName == "User001" || item.Password == "003"


                       select item;


           //使用ToList方法将IEnumerable<UserInfo>类型转换为List<UserInfo>类型


           List<UserInfo> filteredUsers = query.ToList<UserInfo>();


           //将泛型列表绑定DataGridView


           dataGridView1.DataSource = filteredUsers.ToList();


ToDictionary()方法将IEnumerable<TSource>类型的数据转为Dictionary<TKey,TValue>类型的字典。

       var query = from item in users


                       where item.UserName.IndexOf("王") > -1


                       select item;


           //使用ToDictionary方法将query转换为字典类型


            Dictionary<int, UserInfo> userDict = query.ToDictionary(itm => itm.UserCode);


           label1.Text = "Dictionary的结果是:\n";


           foreach (var user in userDict)


           {

               string temp = string.Format("(Key:{0},Value:{1})", user.Key, user.Value.UserName);


               label1.Text += temp + "\n";


           }


当Value为基本数据类型是,例为String类型是,要指定转化的字段。上述例可以改为:    Dictionary<int, string> userDict = query.ToDictionary(itm => itm.UserCode,r=>r.UserName);


           label1.Text = "Dictionary的结果是:\n";


           foreach (var user in userDict)


           {

               string temp = string.Format("(Key:{0},Value:{1})", user.Key, user.Value);


               label1.Text += temp + "\n";


           }


ToLookup方法:Enumerable类的ToLookup方法用来按键值将源序列中的元素放入一对多的字典序列,其语法如下:        //

public static ILookup<TKey, TSource> ToLookup<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector);


参数说明:


      TKey:keySelector返回的键类型。


      TSource:source中的元素类型。


      source:IEnumerable<TSource>类型的源序列,将从它创建一个Lookup<TKey,TValue>类型的一对多字典。


      keySelector System.Func<TSource,TKey>类型,用于每个元素中提取键的函数


      返回值: 一个包含键和值得Lookup<TKey,TValue>


例:


   //构造泛型列表


           List<UserInfo> users = new List<UserInfo> {

           new UserInfo{UserCode=1, UserName="User001", Password="001"},


           new UserInfo{UserCode=1, UserName="User002", Password="002"},


           new UserInfo{UserCode=2, UserName="User003", Password="003"},


           new UserInfo{UserCode=2, UserName="User004", Password="004"}};


           //使用LINQ查找用户代码小于3的列表


           //此时的query变量的类型是IEnumerable<UserInfo>类型


           var query = from item in users


                       where item.UserCode < 3


                       select item;


           //使用ToLookup方法将query转换为一对多字典类型,注意返回的是接口


           ILookup<int, UserInfo> userLookup = query.ToLookup(itm => itm.UserCode);


           label1.Text = "ILookup的结果是:\n";


           foreach (var user in userLookup)//遍历查询结果


           {

               label1.Text += user.Key;//显示主键


               label1.Text += "   ";


               foreach (var user2 in user)//遍历所有值


               {

                   label1.Text += user2.UserName + " , ";//显示键值


               }


               label1.Text += "\n";


           }

tt.png

注:实现ILookup的排序:


Var ord= userLookup.OrderByDescending(r=>r.key);


Cast方法:用来将IEnumerable的元素转换为指定的类型,其语法格式如下:

     public static IEnumerable<TResult> Cast<TResult>(this IEnumerable source);


    参数说明:


      TResult:source中的元素要转换成的类型。


         source:包含要转换的元素的IEnumerable


         返回值:一个IEnumerable<T> ,包含已转换为指定类型的源序列的每个元素。


例:


  string[] strs = { "Mary", "Rose", "Jack", "Peter" };//定义字符串数组



IEnumerable<string> strIESource = strs.Select(i => i.Substring(0, 3));//获取字符串序列


IEnumerable<object> objIEResult = strIESource.Cast<object>();//把字符串序列转为IEnumerable<object>


     foreach (object item in objIEResult)//遍历输出IEnumerable<object>序列


      {

         Console.WriteLine(item.ToString());


          }



第一种:转换为序列:




 IEnumerable<string> strIESource = strs.Select(i => i);//获取字符串序列


           List<string> strListSource = new List<string>(strIESource);//实例化List<string>


           第一种写法:List<object> objListResult = new


List<object>(strListSource.Cast<object>());//把List<string>转换为List<object>


           第二种写法:   List<object> objListResult = strListSource.Cast<object>().ToList();    //把List<string>转换为List<object>


           Console.WriteLine("把List<string>转换为List<object>的运行结果:");


           foreach (object item in objListResult)//遍历输出List<object>集合


           {

               Console.WriteLine(item.ToString());


           }


第二种转换:将List<string>转换为List<object>的运行结果



Linq应用举例:


使用Repeat创建随机数生成器

     static void Main(string[] args)


       {

           Random rand = new Random();//创建一个随机数生成器


           Console.WriteLine("请输入一个整数:");


           try


           {

               int intCount = Convert.ToInt32(Console.ReadLine());//输入要生成随机数的组数


               //生成一个包含指定个数的重复元素值的序列,


               //由于Linq的延迟性,所以此时并不产生随机数,而是在枚举randomSeq的时候生成随机数


               IEnumerable<int> randomSeq = Enumerable.Repeat<int>(1, intCount).Select(i => rand.Next(1,100));


               Console.WriteLine("将产生" + intCount.ToString() + "个随机数:");


               foreach (int item in randomSeq)//通过枚举序列来生成随机数,


               {

                   Console.WriteLine(item.ToString());//输出若干组随机数


               }


           }



请输入一个整数:


5


将产生5个随机数:


78


47


88


95


51


           catch (Exception ex)



           {

               Console.WriteLine(ex.Message);


           }


           Console.Read();


       }


使用Concat连接两个数组

 static void Main(string[] args)


       {

           Program p = new Program();//创建Program对象,用来调用类的方法


           string[] P_str_Name = { "C#编程全能词典", "C#编程词典个人版", "C#编程词典企业版" };      //定义字符串数组


           string[] P_str_Money = { "98元", "698元", "2998元" };//定义字符串数组


           Console.WriteLine("这两组数组的元素:");


           p.TestB(P_str_Name, P_str_Money);//调用方法输出两个数组中的所有元素


           Console.Read();


       }


       //该方法实现连接两个字符串,并输出所有的元素


       private void TestB(string[] str1s, string[] str2s)


       {//第一种遍历方式,使用ForEach:


str1s.Concat<string>(str2s).ToList().ForEach(p => Console.Write(p+"  "));


           foreach (string item in str1s.Concat<string>(str2s))//数组str1s与数组str2s连接,然后遍历,常规的便利方式


           {

               Console.Write(item + "  ");


           }



输出结果:


这两组数组的元素:


C#编程全能词典  C#编程词典个人版  C#编程词典企业版  98元  698元  2998元


       }









按照开始字母的条件,找出单词

string[] strings = { "A penny saved is a peny earned.", "The early bird catches the worm.", "The pen is mightier than the sword" };


           var earlyBirdQuery = from sentence in strings let words = sentence.Split(' ') from word in words let w = word.ToLower()


                                where w[0] == 'a' || w[0] == 'e' || w[0] == 'i' || w[0] == 'o' || w[0] == 'u' select word;


           foreach (var v in earlyBirdQuery)


           {

               Console.WriteLine("\"{0}\" Start with a vowel",v);


           }


"A" Start with a vowel


"is" Start with a vowel


"a" Start with a vowel


"earned." Start with a vowel


"early" Start with a vowel


"is" Start with a vowel


从一篇英文文章中找出所有的单词,并统计单词的重复次数。

     public partial class Frm_Main : Form


   {

       public Frm_Main()


       {

           InitializeComponent();


       }



       private void Frm_Main_Load(object sender, EventArgs e)


       {

           //声明字符串


           string text = @"var query = from info in infoList


   where info.AuditFlag == null || info.AuditFlag == false


   join emp in empList


      on info.SaleMan equals emp.EmployeeCode


   join house in houseList


      on info.WareHouse equals house.WareHouseCode


   join client in clientList


      on info.ClientCode equals client.ClientCode


   join dictPayMode in dictList


      on info.PayMode equals dictPayMode.ValueCode


   where dictPayMode.TypeCode == 'PayMode\'


   join dictInvoiceType in dictList


      on info.InvoiceType equals dictInvoiceType.ValueCode


   where dictInvoiceType.TypeCode == 'InvoiceType'


   select new


   {

      id = info.ID,


      SaleBillCode = info.SaleBillCode,


      SaleMan = emp.Name,


      SaleDate = info.SaleDate,


      Provider = client.ShortName,


      WareHouse = house.ShortName,


      PayMode = dictPayMode.ValueName,


      InvoiceType = dictInvoiceType.ValueName,


      InvoiceCode = info.InvoiceCode,


      AuditFlag = info.AuditFlag


   };";


    //按单词转换为数组


 string[] allWords = (from n in System.Text.RegularExpressions.Regex.Split(text, "[^A-Za-z]") let word = n.ToLower() where word.Length > 0 select n).ToArray();


string[] distinctWords = allWords.Distinct().ToArray<string>();//去掉单词数组中重复的单词


// 第一种方式



 int[] counts = new int[distinctWords.Length];//创建一个存放词频统计信息的数组


       for (int i = 0; i < distinctWords.Length; i++)//遍历每个单词


        {

          string tempWord = distinctWords[i];


          var query = from item in allWords where item.ToLower() == tempWord.ToLower()  select item; //计算每个单词出现的次数


               counts[i] = query.Count();


           }


           //输出词频统计结果


           for (int i = 0; i < counts.Count(); i++)


           {

               label1.Text+=distinctWords[i] + "出现 " + counts[i].ToString() + " 次\n";


           }


      }



//第二种方式:将结果保存为键值对的形式




Dictionary<string, int> dicQuery = queryList.ToDictionary(r => r.key, r => r.keyCount);


           dicQuery.ToList().ForEach(r => label1.Text += r.Key + "出现" + r.Value + "次\n");



List<string> wordList = new List<string>(distinctWords);


           List<string> allWordList = new List<string>(allWords);


           var queryList = from word in wordList


                           select new


                           {

                               key = word,


                               keyCount = allWordList.Count(p => p == word)


                           };


           foreach (var query in queryList)


           {

               label1.Text += query.key + "出现:" + query.keyCount + "次\n";


           }//遍历方式,可以改为如下:




 



}


groupBy字句实现元素按长度分组,group字句用于对查询的结果进行分组,并返回一个IGrouping<TKey,TElment>对象序列,by字句表示按指定条件进行分组,如本实例中按照元素的长度进行分组;into 字句可以创建一个历史标识符,使用该符号可以存储group、join或Select字句的结果。例:

public partial class Frm_Main : Form


   {

       public Frm_Main()


       {

           InitializeComponent();


       }


       private void Frm_Main_Load(object sender, EventArgs e)


       {

           string[] Words = new string[] { "what", "is", "your", "name", "?", "my", "name", "is", "lyf", "." };


           var Groups = from word in Words


           group word by word.Length into lengthGroups//按单词长度将单词分组


                    orderby lengthGroups.Key descending//按单词长度降序排列


           select new


            {

               Length = lengthGroups.Key,//取单词长度


               WordCollect = lengthGroups//取该长度的单词分组集合


            };


  foreach (var group in Groups)//遍历每组单词


  {

      label1.Text +="包含" + group.Length.ToString() + "个字符的单词有:" + "\n";


      foreach (string word in group.WordCollect)


      {

           label1.Text +="    " + word + ",";


      }


      label1.Text +="\n" ;


    }


  }


}


tt.png

tt.png



join 和join into的区别。

public struct Users


   {

       private string name;


       private int id;


       public string Name


       {

           get { return name; }


       }


       public int Id


       {

           get { return id; }


       }


       public Users(string name, int id)


       {

           this.name = name;


           this.id = id;


       }


   }


   public struct Order


   {

       private int id;


       private float money;


       public int Id { get { return id; } }


       public float Money { get { return money; } }


       public Order(int id, float money)


       {

           this.id = id;


           this.money = money;


       }


   }


   class Program


   {    


       static void Main(string[] args)


       {

           Users[] us=new Users[]{new Users("王某",001),new Users("蔡某",002),new Users("刘某",003)};


           Order[] od = new Order[] { new Order(001, 130), new Order(002, 510), new Order(003, 200), new Order(001, 1022), new Order(003, 355) };


           var join = us.Join(od, u => u.Id, o => o.Id, (u, o) => new { u.Id, u.Name, o.Money });


           Console.WriteLine("使用Join方法连接结果如下:");


           foreach (var item in join)


           {

               Console.WriteLine(item);


           }


           var join_into = from u in us


                           join o in od on u.Id equals o.Id


                               into userOrder


                           select new { u.Name, Num = userOrder.Count() };


           Console.WriteLine("使用Join into子句连接结果如下:");


           foreach (var item in join_into)


           {

               Console.WriteLine(item);


           }


       }


}


输出结果:


使用Join方法连接结果如下:


{ Id = 1, Name = 王某, Money = 130 }


{ Id = 1, Name = 王某, Money = 1022 }


{ Id = 2, Name = 蔡某, Money = 510 }


{ Id = 3, Name = 刘某, Money = 200 }


{ Id = 3, Name = 刘某, Money = 355 }


使用Join into子句连接结果如下:


{ Name = 王某, Num = 2 }


{ Name = 蔡某, Num = 1 }


{ Name = 刘某, Num = 2 }




tt.png

目录
相关文章
|
Ubuntu Windows
【Ubuntu/Arm】Ubuntu 系统如何链接有线网络(非虚拟机)?
【Ubuntu/Arm】Ubuntu 系统如何链接有线网络(非虚拟机)?
|
C# 前端开发
WPF DatePicker默认显示当前日期,格式化为年月日
原文:WPF DatePicker默认显示当前日期 WPF的日历选择控件默认为当前日期,共有两种方法,一种静态,一种动态。 静态的当然写在DatePicker控件的属性里了,动态的写在对应的cs文件里,具体请看下面。
7184 0
|
12月前
|
网络协议 Java 数据安全/隐私保护
吃透OSI七层模型:从底层逻辑到实战落地,一文打通网络通信任督二脉
本文从“底层逻辑拆解+权威标准解读+可落地实战示例”三个维度,用通俗的语言讲透OSI七层模型的每一个细节。所有内容均参考ISO/IEC 7498-1官方标准(OSI模型的权威定义),核心论点100%有据可依;实战示例基于Java语言实现,确保可直接编译运行;同时针对易混淆技术点进行明确区分,帮你真正做到“知其然,更知其所以然”。
3344 2
|
7月前
|
存储 弹性计算 人工智能
阿里云服务器租用教程参考:云服务器购买流程,最新优惠政策解析
首次接触阿里云服务器的用户,租用需先注册账号并完成实名认证(个人/企业分通道)。当前热门产品价格:轻量应用服务器2核2G年付38元,2核4G月付9.9元、年付199元,经济型e实例年付99元,u1实例年付199元,c9i实例年付5958.52元起。优惠活动涵盖"99计划"长效普惠、学生300元无门槛抵扣金、企业上云扶持及5亿算力补贴等。建议用户按身份匹配产品、善用优惠券、选择年付及节省计划以控制长期成本,为不同需求用户提供上云参考策略。
|
SQL 数据管理 BI
SQL 有哪些版本?
SQL 有哪些版本?
2339 5
Unity精华☀️一、从旋转到万向锁之:Unity的旋转
Unity精华☀️一、从旋转到万向锁之:Unity的旋转
LiveCharts 直方图详解,安装和使用,以及常用属性的说明
本文介绍了LiveCharts在WPF中的应用,包括安装方法、基本使用和直方图(LineSeries)的常用属性说明。安装LiveCharts通过NuGet包管理器进行,使用时需在XAML文件中引入相应的命名空间。文章还提供了直方图的属性详解和综合示例,包括线条样式、坐标轴标签、图例位置等设置,以及如何自定义数据点形状。
LiveCharts 直方图详解,安装和使用,以及常用属性的说明
|
开发框架 前端开发 JavaScript
循序渐进介绍基于CommunityToolkit.Mvvm 和HandyControl的WPF应用端开发(10) -- 在DataGrid上直接编辑保存数据
循序渐进介绍基于CommunityToolkit.Mvvm 和HandyControl的WPF应用端开发(10) -- 在DataGrid上直接编辑保存数据
|
算法 定位技术 vr&ar
一文了解PnP算法,python opencv中的cv2.solvePnP()的使用,以及使用cv2.sovlePnP()方法标定相机和2D激光雷达
一文了解PnP算法,python opencv中的cv2.solvePnP()的使用,以及使用cv2.sovlePnP()方法标定相机和2D激光雷达
7494 0
一文了解PnP算法,python opencv中的cv2.solvePnP()的使用,以及使用cv2.sovlePnP()方法标定相机和2D激光雷达
|
SQL 运维 监控
安全设备篇——WAF
**Web应用防火墙(WAF)摘要** WAF是关键的网络安全工具,专注于Web应用防护,提供应用层保护,具备事前预防、事中响应和事后审计功能。它通过HTTP/HTTPS策略阻止恶意请求,防止SQL注入、XSS攻击等,并能防止会话劫持、DDoS攻击。WAF支持自定义规则、日志监控和与其他安全产品集成。其特点包括异常检测、输入验证、安全规则库、用户行为分析及多种部署模式如透明网桥、单机和旁路反向代理。与传统防火墙不同,WAF在应用层工作,提供更具体的安全防护。两者结合可增强整体网络安全性。
安全设备篇——WAF