Append Characters to Left of any String -- Use of PadLeft function

Hello everyone !

I heard the function of padLeft,padright in my college.I thought ,
what is the need of this function, where we used it.I skip this function and called it "useless".

but at the time of programming in VS.Net , i got a issue that is To append zeros at left side of a string say "61" and its should be 10 digit string like that "0000000061" then, I start coding ,try to applying "***for if,,,,while & logic****** Select Case**** ".

Result : Partially successful , but code was not feasible,reliable....in short.. fail !

Then, while solving the online practice test ,i got the questions of padleft.I was clueless,and remember my carelessness.

I got a clue from that test,also got an idea that i can use this function for appending any character to a string at right side or left side of it.


So
suppose you have string say "61", and you want make it 10 digits string, with zero's
at leftside then use padleft function.


string strCode="61";
string strCode=strCode.ToString.PadLeft(10, "0"c) ;

padleft Function
1st parameter-width of Integer 10
2nd parameter- Character to be append "0c"

Output will be Consiole.writeline("strCode "&strcode) ; ----> 0000000061



Every function has some importance ,who knows at what time u need it !!

Comments

Popular posts from this blog

Difference Between ArrayList and Generic.List C#/VB.Net

String Function in SQL-Substring,Reverse,CharIndex

Cloud and How I cleared AZ-900 Microsoft Azure Fundamental exam and Why I choose fundamental