Get first 18 characters

mail@pastecode.io avatar
unknown
csharp
3 years ago
1.2 kB
13
Indexable
Never
 // Characters in range 1-18
        public static string GetConfirmCardId(string inputString)
        {
            char[] arrChar = inputString.ToCharArray();
            string result = "";
            for (int i = 0; i < arrChar.Length - 1; i++)
            {
                if (i < 18)
                {
                    result += arrChar[i];
                }
                else
                {
                    break;
                }
            }
            return result;
        }
        
        // In another class
        private void JsutForFun()
        {
            string sourceData = "11054-VC          CU      108     11054-VC          108 000000000000000000000000000000000000000           ";
            string first = GetConfirmCardId(sourceData);// "11054-VC          "
            string second = GetConfirmCardId(sourceData);// "1054-VC          1"
            bool isEqual = AreTwoCodeIdentical(first, second);
            // isEqual == false
            
        }
        
        private bool AreTwoCodeIdentical(string firstCode, string secondCode)
        {
            return firstCode.Equal(secondCode);
        }