C# for Beginner Part 45 to 55

Part 45   C# Tutorial   Why Enums

Enums are strongly typed constants.

If a program uses set of integral numbers, consider replacing them with enums. Otherwise the pragram becomes less

Readable Maintainable

Part 46   C# Tutorial   Enums Example

public enum gender

{

male,

female

}

Part 47   C# Tutorial   Enums in c#

1,Enums are enumerations.

2,Enums are strongly typed constants(常量). Hence(因此),an explicit(显式) cast is needed to convert from enum type to an integral type and vice versa.Also, an enum of one tpe cannot be implicitly(隐式)  assigned(指定) to an enum of another type even though the underlying value of their members are the same.

3,the default underlying type of an enum is int.

4, the defalut value for first element is ZERO and gets incremented(递增) by 1.

5,It is possible to customize the underlying type and values.

6,Enums are value types.

7,Enum keyword(all small letteres) is used to create enumerations, where as Enum class,contains static GetValues() and Get Names() methods which can be used to list Enum underlying type values and Names.

Part 48   C# Tutorial   Difference between Types and Type Members

Part 49   C# Tutorial   Access Modifiers in C#

Part 50   C# Tutorial   Internal and Protected Internal Access Modifiers in C#

Part 51   C# Tutorial   Access Modifiers for types

Part 52   C# Tutorial   Attributes in C#

 Part 53   C# Tutorial   Reflection in C#

Part 54 C# Tutorial Reflection Example

here is the code

private void btnDiscover_Click(object sender, EventArgs e)
{
lbMethods.Items.Clear();
lbProperties.Items.Clear();
lbConstructor.Items.Clear();
string typeName = txtTypeName.Text.Trim();
Type t = Type.GetType(typeName);
if (t == null)
{
MessageBox.Show("Type Is No Exit, Please Enter A Right Type!", "Warnning", MessageBoxButtons.OK);
txtTypeName.Clear();
txtTypeName.Focus();
}
else
{
MethodInfo[] methods = t.GetMethods();
PropertyInfo[] properties = t.GetProperties();
ConstructorInfo[] constructors = t.GetConstructors();
foreach (var method in methods)
{
lbMethods.Items.Add(string.Concat(method.ReturnType.Name," ", method.Name));
}
foreach (var property in properties)
{
lbProperties.Items.Add(string.Concat(property.PropertyType.Name, " ", property.Name));
}
foreach (var constructor in constructors)
{
lbConstructor.Items.Add(constructor.ToString());
}
}
}

Part 55   C# Tutorial   Late binding using reflection

时间: 2024-08-05 02:14:47

C# for Beginner Part 45 to 55的相关文章

2017年上半年软考心上午45下午55分!

这已是我参加的第二次计算机网络工程师,严格来说是第三次,因为2016年上半年第一次由于根本没有任何准备,加上但是赶考路线不熟且天降大雨,半路弃考.2016年下半年第二次备考全凭看书,做遍历年习题,考试也并不难,都在自己掌握范围之内,本以为十拿九稳,但结果是上午46分下午41分惜败(如图).痛苦了好几天,损失太大了,因为我们的工资待遇是和职称挂钩的,中级职称工资能加2900大洋.考后疼定思疼,经总结光看书还是不行的,于是乎在网上找到了51cto,可以视频跟踪培训,更重要的是有学习群,不懂得地方可以

世界主要城市经纬度

城市英文名 城市中文名 所属国家 纬度 经度 Abidjan 阿比让 科特迪瓦 北纬:5°19' 东经:4°01' Abu Dhabi 阿布扎比 阿联酋 北纬:24°27' 东经:54°23' Abuja 阿布贾 尼日利亚 北纬:9°12' 东经:7°11' Acapulco 阿卡普尔科 墨西哥 北纬:16°51' 西经:99°56' Accra 阿克拉 加纳 北纬:5°33' 东经:0°15' Adak 艾达克岛 美国 北纬:51°52' 东经:176°39' Adamstown 亚当斯敦 英

用caffe一步一步实现人脸检测

学习深度学习已有一段时间了,总想着拿它做点什么,今天终于完成了一个基于caffe的人脸检测,这篇博文将告诉你怎样通过caffe一步步实现人脸检测.本文主要参考唐宇迪老师的教程,在这里感谢老师的辛勤付出. 传统机器学习方法实现人脸检测: 人脸检测在opencv中已经帮我们实现了,我们要把它玩起来很简单,只需要简简单单的几行代码其实就可以搞定.(haarcascade_frontalface_alt.xml这个文件在opencv的安装目录下能找到,笔者的路径是:E:\opencv2.4.10\ope

Python中的切片操作

Python中的切片操作功能十分强大,通常我们利用切片来进行提取信息,进行相关的操作,下面就是一些切片的列子,一起来看看吧,希望对大家学习python有所帮助. 列如我们从range函数1-100中取7的倍数,函数及结果如下所示: >>> for i in range(1,100)[6::7]: print i 7 14 21 28 35 42 49 56 63 70 77 84 91 98 取一个list或tuple的部分元素是非常常见的操作.比如,一个list如下: >>

常见排序算法

1. 冒泡排序: 很古板而又很经典的一种排序方式,就是前后两个数据进行对比,然后交换位置即可: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CSP { class Program { static void Main(string[] args) { int [] intList = new

Heartbeat+Drbd+NFS高可用实现

继续之前的操作,来完成heartbeat+drbd+nfs高可用的实现. heartbeat+drbd还是使用原来的环境即可,然而需要添加一台nfs客户端,客户端的信息如下: 主机名 IP地址 角色 server136.contoso.com 192.168.49.136 nfs客户端 一.环境准备 1)注意:因为我的客户端是192.168.49.0/24端,所以这里需要把VIP改为这个网段,所以先修改两个节点的haresources文件,将VIP修改为192.168.49.100.可以根据实际

4.12快速分类

package test; import java.util.Scanner; public class T12Partition { public static int[] a; public int partition(int m,int p){ int v=a[m]; System.out.println("基准元素为:"+v); int i=m+1; while(i<=p){ while(i<=p&&a[i]<v){ i++; } while(

【转】linux设备驱动之MMC SD卡——核心层简单分析

原文网址:http://blog.chinaunix.net/uid-28685940-id-3889878.html /*************************************************************************************************************************************//* bus.c */ /* *  linux/drivers/mmc/core/bus.c * *  Cop

在CentOS 6.4上安装Puppet配置管理工具

在CentOS 6.4上安装Puppet配置管理工具 linux, puppetAdd comments 五052013 上篇说了下在ubuntu12.04上安装puppet,安装的版本为puppet2.7.11版本,今天尝试了下在CentOS6.4系统上安装puppet 3.1.1版本,本文参考chenshake的文章 ? 1 2 3 4 OS:centso 6.4 X64 Puppet 3.1.1 Puppet master: master.canghai.com Puppet client