Hello folk,

I gonna give information about creational design patterns. I gonna explain design patterns in creational design patterns.

What is creational design patterns ?

Creational design patterns are design patterns that deal with object creation. Creational design provide patterns controlling object creation when basically object creation. Creational design patterns…

--

--

Hello folks,

I gonna show a few features on an example in this article with .net core 6 console.

var array = new int[] { 1, 2, 3 };foreach(var a in array){
Console.WriteLine($”Value is {a}”);
}var enumerator = array.GetEnumerator();while (enumerator.MoveNext()){
Console.WriteLine($”Enumerator value is {enumerator.Current}”);
}

In the above example, We have a array and we make the array enumerable with GetEnumerator() function. We use MoveNext() to get next value and we print next value with “Current” keyword.

Good luck.

previous post: https://taskinbinbir.medium.com/what-is-enumeration-f7b09c579728

--

--

Hello everbody,

An enum, just like a class, have attributes and methods.
An Enum constants are always public static and final.
Some uses of enums are like month days, days, colors and more.

Basic enum DescriptionAttribute sample, following,

public enum Colors{[Description("Red")]Red,[Description("White")]White,[Description("Blue")]Blue,[Description("Green")]Green}

Basic enum method sample, following,

using System;using System.ComponentModel;namespace EnumApp{public enum Colors{  [Description("Red")]   Red,  [Description("White")]   White,   [Description("Blue")]   Blue,   [Description("Green")]   Green}class Program{   static void Main(string[] args)   {     String color = "White";     switch(color)     {       case "Red":        Console.WriteLine("Color is " + Colors.Red);       break;       case "White":        Console.WriteLine("Color is " + Colors.White);       break;       case "Blue":        Console.WriteLine("Color is " + Colors.Blue);       break;       case "Green":        Console.WriteLine("Color is " + Colors.Green);       break;      default:       Console.WriteLine($"{color} is a unknown color by system");      break;  }   Console.ReadLine();  } }}

Good luck.

--

--

Enumeration is in c#, also that is iteration in other languages. So, Enumeration is actually iteration.

A quick sample, following;

class Program{static void Main(string[] args){Program p = new Program();foreach(var c in p.GetCars()){Console.WriteLine(c);}Console.ReadLine();}IEnumerable<string> GetCars(){  yield return "BMW";  yield return "Mercedes";  yield return "Audi";}}

By debugging this example, you can see that the returns are coming one by one.

--

--