With Char for loop

My question; I want two different char value from user. For example BlockStart=a and BlockFinish=d
after then I want doing for loop ‘d’ to ‘a’
I did BlockStart and BlockFinish properties char type and
I prepared for loop:
{ for (char i = dto.BlockStartAlphabetical; i <= dto.BlockFinishalphabetical; i++) {} }

but this expression don’t come in for loop.
What can I do?

>Solution :

Well you can use linq in a way that helps you to build an array of characters like below :

var start = 'a';
var end = 'd';
var result = Enumerable.Range(0,end-start+1).Select(ix=> (char)(start+ix)).ToArray();

// result = [a,b,c,d]

Fiddle

Leave a Reply