Click here to Skip to main content
15,919,121 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi all, i wanna ask you about function that is built-in .net.
For example, if we want to make batch number like this : "0001", we can make in our code like this :
batch.PadLeft(4, "0");


But, if i have a string which have a format like this :
VB
BankID|ExtRef|SeqNum|AC|CurCod|ValDate|OpenBal|ValDate|TrxtRef|TrxType|DC|CashVa
l|Description|CloseBal|Note


The main question is how to get BankID, ExtRef, SeqNum, etc..??

Is there any function that is built in .NET like "PadLeft"?? Or i must start reading this format by using StreamReader and then start split one by one, so i can get BankID, ExtRef, etc..???

May you give me any suggestion for this format..?? :~
Posted
Updated 27-Sep-10 1:32am
v3
Comments
Hiren solanki 27-Sep-10 7:37am    
probaly you could use Split('|') function in .Net.
Teamsar Muliadi 27-Sep-10 7:49am    
Mmm.. ok.. but how to get BankID, ExtRef, SeqNum.. if i have splited this string.. and the result like this :
BankIDExtRefSeqNumACCurCodValDateOpenBalValDateTrxtRefTrxTypeDCCashValDescriptionCloseBalNote
NB : Length of each other is different.. and we don't know about its length (BankID, ExtRef, SeqNum.. etc)

1 solution

To split a string, do something like this:

string myString = "BankID|ExtRef|SeqNum|AC|CurCod|ValDate|OpenBal|ValDate|TrxtRef|TrxType|DC|CashVal|Description|CloseBal|Note"

string[] parts = myString.Split('|');


At this point, your string is split into the various parts that are separated by the '|' character. What does PadLeft have to do with what you apparently want to do?
 
Share this answer
 
Comments
Hiren solanki 27-Sep-10 7:48am    
I am bit confusing why he want to use padleft,though he just want splitted strings.
Teamsar Muliadi 27-Sep-10 7:57am    
Hehehe.. sorry.. if "padleft" in my description is meaningless or has no a meaning.. :)
The point of my question is, is there any "built in" function to handle the format.. thank you.. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900