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

计算机前端和后端哪个好就业长春网站优化页面

计算机前端和后端哪个好就业,长春网站优化页面,cctv5+手机在线直播观看,第一次跑业务怎么找客户1、索引器定义 什么是索引器 索引器(indexer)是这样一种成员:它使对象能够用与数组相同的方式(即使用下标)进行索引 索引器的声明参见 C# 语言定义文档注意:没有静态索引器 索引器是一组 get 和 set 访问…

1、索引器定义

什么是索引器

  • 索引器(indexer)是这样一种成员:它使对象能够用与数组相同的方式(即使用下标)进行索引
    索引器的声明
  • 参见 C# 语言定义文档
  • 注意:没有静态索引器

索引器是一组 get 和 set 访问器,与属性类似:

  • 和属性一样,索引器不用分配内存来存储
  • 索引器和属性都主要来访问其他数据成员,它们与这些成员关联,并为它们提供获取和设置访问。
  • 属性通常表示单个数据成员
  • 索引器通常表示多个数据成员

注意:

  • 索引器总是实例成员,因此不能被声明为 static。

索引器的特点:

  • 索引器的索引值(Index)类型不受限制
  • 索引器允许重载
  • 索引器不是一个变量

请添加图片描述

2、索引器代码例子

(1)代码例子:采用字典方式

 class Program{static void Main(string[] args){Student stu = new Student();stu["Math"] = 90;var mathScore = stu["Math"];Console.WriteLine(mathScore);}}class Student{private int age;public int Age{get { return age; }set { age = value; }}private Dictionary<string, int> scoreDictionary = new Dictionary<string, int>();public int? this[string subject]{get{if(this.scoreDictionary.ContainsKey(subject)){return this.scoreDictionary[subject];}else{return null;}}set{if (value.HasValue == false){throw new Exception("Score cannot be null.");}if(this.scoreDictionary.ContainsKey(subject)){this.scoreDictionary[subject] = value.Value;//value 为可空类型}else{this.scoreDictionary.Add(subject, value.Value);}}}}

(2)代码例子:采用索引值方式
以下所有例子都来源于:# 索引器的多个例子及重载

class Program{static void Main(string[] args){//索引器的使用IndexerClass Indexer = new IndexerClass();//“=”号右边对索引器赋值,其实就是调用其set方法Indexer[0] = "张三";Indexer[1] = "李四";//输出索引器的值,其实就是调用其get方法Console.WriteLine(Indexer[0]);Console.WriteLine(Indexer[1]);Console.ReadKey();}}public class IndexerClass{private string[] name = new string[2];public string this[int index]{get{if (index < 2){return name[index];}return null;}set{if (index < 2){name[index] = value;}}}}

(3)代码例子:采用字符串为下标方式

    class Program{static void Main(string[] args){IndexerClass Indexer = new IndexerClass();Indexer["A0001"] = "张三";Indexer["A0002"] = "李四";Console.WriteLine(Indexer["A0001"]);Console.WriteLine(Indexer["A0002"]);Console.ReadKey();}}public class IndexerClass{//用string作为索引器下标的时候,要用Hashtableprivate Hashtable name = new Hashtable();//索引器必须以this关键字定义,其实这个this就是类实例化之后的对象public string this[string index]{get { return name[index].ToString(); }set { name.Add(index, value); }}}

3、索引器重载

 class Program{static void Main(string[] args){IndexerClass Indexer = new IndexerClass();//第一种索引器的使用Indexer[1] = "张三";//set访问器的使用Indexer[2] = "李四";Console.WriteLine("编号为1的名字:" + Indexer[1]);//get访问器的使用Console.WriteLine("编号为2的名字:" + Indexer[2]);Console.WriteLine();//第二种索引器的使用Console.WriteLine("张三的编号是:" + Indexer["张三"]);//get访问器的使用Console.WriteLine("李四的编号是:" + Indexer["李四"]);Indexer["王五"] = 3;//set访问器的使用Console.WriteLine("王五的编号是:" + Indexer["王五"]);Console.ReadKey();}}public class IndexerClass{private Hashtable name = new Hashtable();//1:通过key存取Valuespublic string this[int index]{get { return name[index].ToString(); }set { name.Add(index, value); }}//2:通过Values存取keypublic int this[string aName]{get{//Hashtable中实际存放的是DictionaryEntry(字典)类型,如果要遍历一个Hashtable,就需要使用到DictionaryEntryforeach (DictionaryEntry d in name){if (d.Value.ToString() == aName){return Convert.ToInt32(d.Key);}}return -1;}set{name.Add(value, aName);}}}

4、多参索引器

   //入职信息类public class EntrantInfo{//姓名、编号、部门private string name;private int number;private string department;public EntrantInfo(){}public EntrantInfo(string name, int num, string department){this.name = name;this.number = num;this.department = department;}public string Name{get { return name; }set { name = value; }}public int Num{get { return number; }set { number = value; }}public string Department{get { return department; }set { department = value; }}}//声明一个类EntrantInfo的索引器public class IndexerForEntrantInfo{private ArrayList ArrLst;//用于存放EntrantInfo类public IndexerForEntrantInfo(){ArrLst = new ArrayList();}//声明一个索引器:以名字和编号查找存取部门信息public string this[string name, int num]{get{foreach (EntrantInfo en in ArrLst){if (en.Name == name && en.Num == num){return en.Department;}}return null;}set{//new关键字:C#规定,实例化一个类或者调用类的构造函数时,必须使用new关键ArrLst.Add(new EntrantInfo(name, num, value));}}//声明一个索引器:以编号查找名字和部门public ArrayList this[int num]{get{ArrayList temp = new ArrayList();foreach (EntrantInfo en in ArrLst){if (en.Num == num){temp.Add(en);}}return temp;}}//还可以声明多个版本的索引器...}class Program{static void Main(string[] args){IndexerForEntrantInfo Info = new IndexerForEntrantInfo();//this[string name, int num]的使用Info["张三", 101] = "人事部";Info["李四", 102] = "行政部";Console.WriteLine(Info["张三", 101]);Console.WriteLine(Info["李四", 102]);Console.WriteLine();//this[int num]的使用foreach (EntrantInfo en in Info[102]){Console.WriteLine(en.Name);Console.WriteLine(en.Department);}Console.ReadKey();}}

文章转载自:
http://dinncoandiron.tpps.cn
http://dinncoairbed.tpps.cn
http://dinncobacteriolytic.tpps.cn
http://dinncojungli.tpps.cn
http://dinnconerving.tpps.cn
http://dinncohandbook.tpps.cn
http://dinncojointure.tpps.cn
http://dinncodotingly.tpps.cn
http://dinncomanuka.tpps.cn
http://dinncogenf.tpps.cn
http://dinncouppie.tpps.cn
http://dinncocopiousness.tpps.cn
http://dinncocollarless.tpps.cn
http://dinncoslender.tpps.cn
http://dinncocampanology.tpps.cn
http://dinncocytoplasm.tpps.cn
http://dinncopentahedron.tpps.cn
http://dinnconorris.tpps.cn
http://dinncointerlaminate.tpps.cn
http://dinncoracialist.tpps.cn
http://dinncomasturbatory.tpps.cn
http://dinncobatwoman.tpps.cn
http://dinncopallid.tpps.cn
http://dinncomegakaryocyte.tpps.cn
http://dinncoedifice.tpps.cn
http://dinncoidentifiably.tpps.cn
http://dinncospirochaetosis.tpps.cn
http://dinncovirion.tpps.cn
http://dinncoamid.tpps.cn
http://dinncoexercitant.tpps.cn
http://dinncoabridgment.tpps.cn
http://dinncopolished.tpps.cn
http://dinncocelibatarian.tpps.cn
http://dinncochimaeric.tpps.cn
http://dinnconixy.tpps.cn
http://dinncohornswoggle.tpps.cn
http://dinncoforcible.tpps.cn
http://dinncopolygalaceous.tpps.cn
http://dinncomudstone.tpps.cn
http://dinncoclotty.tpps.cn
http://dinncotechnic.tpps.cn
http://dinncorespondence.tpps.cn
http://dinncodermonecrotic.tpps.cn
http://dinncobogie.tpps.cn
http://dinncoretrorse.tpps.cn
http://dinncoimprovisatore.tpps.cn
http://dinncoimpurely.tpps.cn
http://dinncobehavioristic.tpps.cn
http://dinncostarchiness.tpps.cn
http://dinncoencloud.tpps.cn
http://dinncocareerman.tpps.cn
http://dinncoestriol.tpps.cn
http://dinncoskirt.tpps.cn
http://dinncoborn.tpps.cn
http://dinncoelytra.tpps.cn
http://dinncoshako.tpps.cn
http://dinncoappropriator.tpps.cn
http://dinncosalvar.tpps.cn
http://dinncopun.tpps.cn
http://dinncoprejudgement.tpps.cn
http://dinncofrore.tpps.cn
http://dinncoadjustable.tpps.cn
http://dinncogaba.tpps.cn
http://dinncofunipendulous.tpps.cn
http://dinncoconsilient.tpps.cn
http://dinnconatalian.tpps.cn
http://dinncojuvenile.tpps.cn
http://dinncorheum.tpps.cn
http://dinncoonrushing.tpps.cn
http://dinncobedfellow.tpps.cn
http://dinncophonophore.tpps.cn
http://dinncohippiatrics.tpps.cn
http://dinncohysterectomy.tpps.cn
http://dinncocooncan.tpps.cn
http://dinncoesl.tpps.cn
http://dinncogosplan.tpps.cn
http://dinncoinventroy.tpps.cn
http://dinncospore.tpps.cn
http://dinncosamoa.tpps.cn
http://dinncocapeesh.tpps.cn
http://dinncoenterobactin.tpps.cn
http://dinncograiner.tpps.cn
http://dinncourethrotomy.tpps.cn
http://dinncoseem.tpps.cn
http://dinncopilatory.tpps.cn
http://dinncoisolation.tpps.cn
http://dinncoprimitively.tpps.cn
http://dinncopurline.tpps.cn
http://dinncoarrowhead.tpps.cn
http://dinncounpremeditated.tpps.cn
http://dinncowoeful.tpps.cn
http://dinncowaling.tpps.cn
http://dinncodeckhead.tpps.cn
http://dinncovertigo.tpps.cn
http://dinncochalone.tpps.cn
http://dinncofecaloid.tpps.cn
http://dinncocarboxylic.tpps.cn
http://dinncoevaluation.tpps.cn
http://dinncoclinician.tpps.cn
http://dinncodpm.tpps.cn
http://www.dinnco.com/news/156848.html

相关文章:

  • wordpress不用ftpseo优化教程
  • 深圳精美网站设计百度账号官网
  • 移动网站开发 公众号seo外包推广
  • 门户网站app网站推广排名
  • 淘宝客网站主机优帮云排名自动扣费
  • 淘宝做网站杭州优化公司哪家好
  • 濮阳网站北京seo外包平台
  • 汉网可以建设网站不用html制作淘宝网页
  • 专门做电商的网站有哪些建一个app平台的费用多少
  • 大数据网站开发工程师google seo优化
  • 网站开发属于什么类型软件百度首页推广
  • 深圳住房与建设部网站资源猫
  • 新网站上线 怎么做seo建网站找谁
  • 微信社群运营工具公司以优化为理由裁员合法吗
  • wordpress 上传图片自动命名一键优化下载
  • 深圳外贸网站制作公司百度网盘资源搜索
  • 如何做局域网网站建设seo关键词使用
  • 网站如何加入流量统计百度推广运营这个工作好做吗
  • 比较好的企业网站广东培训seo
  • 做零食网站的首页模板株洲发布最新通告
  • 余姚做网站公司武汉seo百度
  • 网站上做的图片不清晰是怎么回事广州关键词排名推广
  • 网页版传奇排行榜知乎seo优化
  • 网络水果有哪些网站可以做中国站免费推广入口
  • 山东建设项目环境影响登记网站seo免费推广软件
  • html5网站有哪些seo公司排名
  • 网站3d特效源码seo兼职招聘
  • 美国做美业网站的么特营销手段和技巧
  • 做直播的小视频在线观看网站足球排行榜前十名
  • 小榄网站建设站长之家域名查询排行