C#的扩展方法
首先 这个 扩展方法必须定义到 静态类中, 所以 此方法 也是 一个静态的方法 而且 参数 必须用 this
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace LinqObject.mylinq{ public static class ArrayE{ public static string[] toArrayAiny(this string str) { return str.Split(','); } }}
应用:
string str = "hushcfsdbv,jhvdufhvu,hvudhv";string[] arr = str.toArrayAiny();Console.WriteLine(arr[0]);
结果:
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。