When I need to print “00000”, I can use “0”*5 in python. Is there equivalent in C# without looping?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Based on your example I figure you’re going to be using these strings to help zero-pad some numbers. If that’s the case, it would be easier to use the
String.PadLeft()method to do your padding. You could be using the similar function in python as well,rjust().e.g.,
Otherwise if you need a repeated sequence of strings, you’d want to use the
String.Concat()method in conjunction with theEnumerable.Repeat()method. Using the string constructor only allows repetition of a single character.e.g.,