Part # Tutorial Why Enums
Enums is strongly typed constants.
If a program uses set of integral numbers, consider replacing them with enums. Otherwise the Pragram becomes less
Readable maintainable
Part Tutorial C # Enums Example
public enum gender
{
Male
Female
}
Part Tutorial C # Enums in C #
1,enums is enumerations.
2,enums is strongly typed constants (constant). Hence (therefore), an explicit (explicit) cast is needed to convert the from enum type to an integral type and vice versa. Also, an enum of one TPE cannot is implicitly (implicit) assigned (designation) to an enum of another type even though the underlying Valu E of their members is the same.
3,the default underlying type of an enum is int.
4, the Defalut value for first element is ZERO and gets incremented (incremented) by 1.
5,it is possible to customize the underlying type and values.
6,enums is value types.
7,enum keyword (all small letteres) are 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 Tutorial C # difference between Types and Type members
Part Tutorial C # Access Modifiers in C #
Part # Tutorial Internal and Protected Internal Access Modifiers in C #
Part Wuyi C # Tutorial Access Modifiers for types
Part Tutorial C # Attributes in C #
Part Tutorial C # Reflection in C #
Part Tutorial C # 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 Tutorial C # late binding using reflection
C # for beginner part 55