C# – Creating GUIDs and Working with Enumerations

GUID means Globally Unique Identifier

System.GUID newGUID = System.Guid.NewGuid();

Working with Enumerations

A data type accepting only enumerated values that you define.

Strongly typed, ridding you app  of “magic strings”.

public enum Occupation{
  Doctor,
  Lawyer,
  IndianChef
}
Occupation whatIDo = Occupation.IndianChef;

Occupation occupation;

if(Enum.TryParse("Doctor", out occupation)){
  ......
}
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: