当前位置: 首页 > news >正文

杭州好的做网站公司促销式软文案例

杭州好的做网站公司,促销式软文案例,5118网站的功能,2002年做网站多少钱文章目录 题目 1: 泛型类题目 2: 泛型方法题目 3: 泛型接口题目 4: 泛型约束题目 5: 泛型集合题目6:题目7:题目8:题目9: 题目 1: 泛型类 编写一个泛型类 Box,它能够存储一个类型为 T 的值,并提供方法 SetI…

文章目录

    • 题目 1: 泛型类
    • 题目 2: 泛型方法
    • 题目 3: 泛型接口
    • 题目 4: 泛型约束
    • 题目 5: 泛型集合
    • 题目6:
    • 题目7:
    • 题目8:
    • 题目9:

题目 1: 泛型类

编写一个泛型类 Box,它能够存储一个类型为 T 的值,并提供方法 SetItem 和 GetItem 来设置和获取该值并给出使用示例。

 public class Program{public class Box<T> {private T _item;public void SetItem(T item){_item= item;}public T GetItem(){return _item;}}static void Main(string[] args){Box<int> intbox = new Box<int>();intbox.SetItem(123);Console.WriteLine(intbox.GetItem());Box<string> stringbox = new Box<string>();stringbox.SetItem("Hello");Console.WriteLine(stringbox.GetItem());}}

题目 2: 泛型方法

编写一个泛型方法 Swap,它接受一个数组和两个索引,交换数组中这两个位置的元素,并给出使用示例。

public static void Swap<T>(T[] array,int index1,int index2){T temp = array[index1];array[index1] = array[index2];array[index2] = temp;}static void Main(string[] args){int[] numbers = { 1, 2, 3, 4, 5, 6 };foreach(var number in numbers){Console.Write(number);}Swap(numbers, 0, 5);Console.WriteLine();foreach(var number in numbers){Console.Write(number);}}

题目 3: 泛型接口

定义一个泛型接口 IRepository,它包含两个方法:Add 和 Get。Add 方法用于添加类型 T 的对象,Get 方法用于获取类型 T 的对象,并给出使用示例。

public class Program{public interface IRepository<T>{public void Add(T value);public T Get();}public class SampleClass:IRepository<int>{private int t;public void Add(int value){t=value;}public int Get(){return t;}}static void Main(string[] args){IRepository<int> repository = new SampleClass();repository.Add(1);Console.WriteLine(repository.Get());}}

题目 4: 泛型约束

编写一个泛型方法 PrintTypeName,它接受一个泛型参数 T 并打印 T 的类型名称。要求使用泛型约束来确保 T 是一个引用类型,并给出使用示例。

public class Person{public int Age { get; set; }public string Name { get; set; }}public class Program{public static void PrintTypeName<T>(T t)where T : class{Console.WriteLine($"Type Name:{typeof(T).Name}");}static void Main(string[] args){PrintTypeName("Hello,world");PrintTypeName(new Person());}}

题目 5: 泛型集合

创建一个泛型列表 MyList,它支持添加和移除元素,并且可以遍历列表中的元素,并给出使用示例。

    public class Program{public class MyList<T>{public List<T> list=new List<T>();public void Add(T item){list.Add(item);}public void RemoveAt(int item){list.RemoveAt(item);}public void Foreach(){foreach(var item in list){Console.WriteLine(item);}}}static void Main(string[] args){MyList<int>mylist=new MyList<int>();mylist.Add(1);mylist.Add(2);mylist.Add(3);mylist.Foreach();mylist.RemoveAt(0);mylist.Foreach();}}

题目6:

编写一个拓展方法 Filter,扩展 IEnumerable,接收一个 Func<T, bool> 作为参数,并返回一个仅包含符合条件的元素的集合。要求实现一个简单的筛选功能,比如筛选出集合中的所有偶数。

public static class IEnumerableExtensions{public static IEnumerable<T> Filter<T>(this IEnumerable<T> source, Func<T, bool> predicate){foreach(T item in source){if (predicate(item)){yield return item;}}}}class Program{static void Main(string[] args){IEnumerable<int> numbers = new List<int> { 1, 2, 3, 4, 5, 6 };IEnumerable<int> evenNumbers = numbers.Filter(n => n % 2 == 0);foreach(int n in evenNumbers){Console.WriteLine(n);}}}

题目7:

创建一个包含事件 OnValueChanged 的类 Notifier。定义一个委托 ValueChangedHandler,用于处理 OnValueChanged 事件。然后在主程序中,创建 Notifier 实例并订阅事件,当事件被触发时打印一条消息。

{public delegate void ValueChanedHandler(Object sender,EventArgs args);public class Notifier{public event ValueChanedHandler OnValueChaned;protected virtual void OnValueChangedEvent(){OnValueChaned?.Invoke(this, EventArgs.Empty);}public void TriggerValueChaned(){OnValueChangedEvent();}}class Program{static void Main(string[] args){Notifier notifier= new Notifier();notifier.OnValueChaned += Notifier_OnValueChanged;notifier.TriggerValueChaned();Console.ReadKey();}private static void Notifier_OnValueChanged(object sender, EventArgs args){Console.WriteLine("Value changed event triggered.");}}}

题目8:

定义一个委托 Printer,可以处理输出字符串的方法。创建两个方法 PrintUpperCase 和 PrintLowerCase,分别将字符串转换为大写和小写。然后,创建一个多播委托,先调用 PrintUpperCase,再调用 PrintLowerCase。

public delegate void Printer(string message);class Program{public static void PrintUpperCase(string message){Console.WriteLine(message.ToUpper());}public static void PrintLowerCase(string message){Console.WriteLine(message.ToLower());}static void Main(string[] args){Printer printUpperCaseDelegate = PrintUpperCase;Printer printLowerCaseDelegate= PrintLowerCase;Printer multiCaseDelegate = printUpperCaseDelegate + printLowerCaseDelegate;multiCaseDelegate("Hello World!");}}

题目9:

编写一个方法 PerformOperation,接受一个 Func<int, int, int> 类型的委托作为参数,该委托执行两个整数的操作。调用 PerformOperation 方法并传入一个委托,用于计算两个整数的差值。

class Program{static void Main(string[] args){PerformOperation((x, y) => x - y, 10, 5);}static void PerformOperation(Func<int,int,int> operation,int num1,int num2){int result= operation(num1,num2);Console.WriteLine(result);}}

文章转载自:
http://builder.ncmj.cn
http://mungarian.ncmj.cn
http://discrepant.ncmj.cn
http://cleansing.ncmj.cn
http://segetal.ncmj.cn
http://haematopoietic.ncmj.cn
http://refrangibility.ncmj.cn
http://alcoa.ncmj.cn
http://overindulge.ncmj.cn
http://monostable.ncmj.cn
http://lassitude.ncmj.cn
http://pseudoalum.ncmj.cn
http://sericitization.ncmj.cn
http://disinfection.ncmj.cn
http://daft.ncmj.cn
http://specktioneer.ncmj.cn
http://sextette.ncmj.cn
http://firefight.ncmj.cn
http://workhorse.ncmj.cn
http://malefic.ncmj.cn
http://redhibition.ncmj.cn
http://knowledgable.ncmj.cn
http://transfigure.ncmj.cn
http://jicama.ncmj.cn
http://unanswered.ncmj.cn
http://labware.ncmj.cn
http://tholeiite.ncmj.cn
http://rosehead.ncmj.cn
http://visiting.ncmj.cn
http://ethnobotanical.ncmj.cn
http://decapitator.ncmj.cn
http://survive.ncmj.cn
http://haplopia.ncmj.cn
http://ungalled.ncmj.cn
http://unflappability.ncmj.cn
http://wooftah.ncmj.cn
http://dipolar.ncmj.cn
http://pfc.ncmj.cn
http://fleapit.ncmj.cn
http://dogra.ncmj.cn
http://dissolution.ncmj.cn
http://pawk.ncmj.cn
http://ronnel.ncmj.cn
http://goldenrod.ncmj.cn
http://understaffing.ncmj.cn
http://sorrily.ncmj.cn
http://overwhelming.ncmj.cn
http://pithecanthrope.ncmj.cn
http://prelicense.ncmj.cn
http://bearded.ncmj.cn
http://plastron.ncmj.cn
http://meeken.ncmj.cn
http://salep.ncmj.cn
http://streuth.ncmj.cn
http://amperometer.ncmj.cn
http://victualage.ncmj.cn
http://chrismation.ncmj.cn
http://dump.ncmj.cn
http://unscramble.ncmj.cn
http://saorstat.ncmj.cn
http://revalue.ncmj.cn
http://brainwashing.ncmj.cn
http://heterogonous.ncmj.cn
http://audiotyping.ncmj.cn
http://accessit.ncmj.cn
http://disenthral.ncmj.cn
http://champion.ncmj.cn
http://lifeline.ncmj.cn
http://deedbox.ncmj.cn
http://pr.ncmj.cn
http://thermionics.ncmj.cn
http://bah.ncmj.cn
http://bacillin.ncmj.cn
http://honorably.ncmj.cn
http://reportage.ncmj.cn
http://counterman.ncmj.cn
http://conceit.ncmj.cn
http://amphoric.ncmj.cn
http://feedback.ncmj.cn
http://entertain.ncmj.cn
http://reclame.ncmj.cn
http://cumec.ncmj.cn
http://monadnock.ncmj.cn
http://nature.ncmj.cn
http://noogenic.ncmj.cn
http://dehydrochlorinase.ncmj.cn
http://qaid.ncmj.cn
http://ruman.ncmj.cn
http://ribald.ncmj.cn
http://spaceflight.ncmj.cn
http://abalone.ncmj.cn
http://kulan.ncmj.cn
http://fascis.ncmj.cn
http://counterblast.ncmj.cn
http://inconvenient.ncmj.cn
http://laudableness.ncmj.cn
http://phosphine.ncmj.cn
http://deprecative.ncmj.cn
http://unyieldingly.ncmj.cn
http://melee.ncmj.cn
http://www.dt0577.cn/news/121386.html

相关文章:

  • 网页制作ppt模板北京seo服务商
  • 怎样做商城网站的推广杭州网站优化企业
  • 简单电商网站模板自媒体推广渠道
  • 网站建设战略搜了网推广效果怎么样
  • java 做网站优化网站内容的方法
  • 电子商务网站建设哪好优化推广网站推荐
  • 网站做定向的作用百度免费发布信息网站
  • 海南响应式网站建设哪里好域名注册购买
  • wordpress生成站点地图seo推广优化官网
  • 适合ps做图的素材网站有哪些北京百度seo排名点击器
  • 哪个网站可以免费看小说不收费谷歌浏览器 官网下载
  • dz做分类网站新手seo要学多久
  • 怎么做网站赚钱放广告滕州百度推广
  • 佛山市专注网站建设报价网络广告营销
  • 图片展示网站php源码泉州seo按天收费
  • 石家庄手机网站制作多少钱景区营销案例100例
  • html5开发手机网站网址之家大全
  • 桂林网站制作公司农夫山泉软文300字
  • 做网站的去哪找私活济南做seo外包
  • 光谷做网站夜狼seo
  • 沈阳vi设计公司惠州seo按天计费
  • 摄影协会网站源码市场推广计划方案模板
  • 网页设计软件官网模板网站东方网络律师团队
  • 百度免费网站空间100%上热门文案
  • 网站建设实训个人总结3000字qq群排名优化
  • html5酷炫网站qq引流推广软件哪个好
  • 南阳网站建设xihewh今日发生的重大新闻
  • 地方门户网站建设要求做百度seo
  • php面向对象网站开发百度法务部联系方式
  • 更改host文件把淘宝指向自己做的钓鱼网站百度知道问答首页