Question: I have field type string that can get two type of values on it: 

1. simple field e.g. **p1**
2. complex fields **p1/p2/p3/p4**

Now I have 2 questions:

1. how can I identify that the type is complex **with little effort as possible** since 
the check is runs in loop?
2. when I got type complex I need to store **the last two properties** for 
example p3 and P4?

Answer: 
As mentioned in last post ANSI standard that defines DUKPT, X9.24-1 in 3DES mode, that means Dukpt uses 3DES algorithm to generate Key(not to encrypt or decrypt data) and it is known as 3DES-DUKPT.Another type is AES-DUKPT, which uses AES-ECB mode to generate key.
Both have common inputs Base derivation Key(BDK) and KSN with different size.
For 3DES-DUKPT, BDK = 16 bytes(always) and KSN = 10 bytes.
For AES-DUKPT, BDK = 16, 24, 32 bytes(depend upon AES key size) and KSN = 12 bytes.

Input KSN consist of Key\_serial\_number and Counter.

Input BDK and Key\_serial\_number (from KSN) generates IPEK.
And IPEK with Counter(from KSN) generates Encryption / Decryption key for data.
There is a ANSI standard that defines DUKPT, X9.24-1 but that uses DES both for the encryption/decryption and to produce the keys. Since you said BDK and KSN, I imagine this is what you have in mind. I expect you did not get any responses (even after the extended period of four hours) because you said AES and DUKPT in the same posting. (People in the know read that and say, RTFM.)

It is not C# but I believe there is a DUKPT.m file by "Mikhail Burshteyn" pointed to on Stack Exchange or somewhere in the last six months or so. There is also pieces of code in C that I wrote to illustrate how to decrypt. (Something that is not covered worth a darn in the standard.)

If you want source code in C# that you can cut and paste, I think you will be disappointed.