c# - How can I place zeroes to the left of a given number to a maximum of 6 digits including the given numbers -
I have a method that receives the ID number and downloads an HTML website according to that ID.
Generally, an IMDB link is like this:
http://www.imdb.com/title/tt0892791/ http://www.imdb Com / title / tt1226229 / http: /www.imdb.com/title/tt0000429/
They all follow 'TT', then 7 digits, fill the left spaces Points due to lack of points for >
How can I use C #? I'm kind of stumped.
Here's my method:
/// & lt; Summary & gt; /// Find Movie Pages Using Your Exactly IMDb ID /// & lt; / Summary & gt; /// & lt; Param name = "id" & gt; IMDb Movie ID & lt; / Param & gt; /// & lt; Returns & gt; Returns an HTML document with the source code. & Lt; / Returns & gt; Public HtmlDocument ByID (string id) {string url = String.Format ("http://www.imdb.com/title/tt{0}/", id); HTML document page = downloader.load (url); Return page; }
Thank you very much for your time, and if you are interested in helping, you can see the full source code of TheFreeIMDB here:
Since id
is a string in your sample, id.PadLeft (length, '0') Use
, where length
is the total length you want (in this case: 7).
Comments
Post a Comment