Hi
this.webBrowser1.DocumentText = string.Format(html, "htp://youtu.be/faT7y8NiZ20".Split('=')[1]);
Thanks
Hi
this.webBrowser1.DocumentText = string.Format(html, "htp://youtu.be/faT7y8NiZ20".Split('=')[1]);
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sam HobbsRank #107 · 20.5K reputationPosted Nov 12, 2022, 2:10 AM EST
When you get an error like that you can split the code as in the following.
string html = "Result: {0}"; string url = "htp://youtu.be/faT7y8NiZ20"; string[] sa = url.Split('='); string s = sa[0]; Console.WriteLine(string.Format(html, s)); s = sa[1]; Console.WriteLine(string.Format(html, s));When you run that you will see that a[0] has the entire contents of html but a[1] does not exist and therefore it causes the error. There is no '=' in the input string.
Programmers prefer to do many things in one line of code but that can cause a problem when there is an error, it is more difficult to find the cause of the error.
Sachin SinghRank #66 · 26.2K reputationPosted Nov 12, 2022, 3:27 AM EST
As, Sam sir said , clearly there is no '=' in your url so the split function is throwing the error. please modify your url.
generally the youtuble url is like this
www.youtube.com/watch?v=sS5BCvj6c_0
this url will work when you will split.
Gowtham RamarRank #1,754 · 860 reputationPosted Nov 12, 2022, 3:54 AM EST
Hi,
if ("htp://youtu.be/faT7y8NiZ20".Split('=').length>0){
this.webBrowser1.DocumentText = string.Format(html, "htp://youtu.be/faT7y8NiZ20".Split('=')[1]);
}
Ramco RamcoRank #462 · 5.4K reputationPosted Nov 13, 2022, 9:49 PM EST
Hi
It is giving error Object reference not set to an instance of the object.
string html = ""; html += ""; html += ""; html += ""; this.webBrowser1.DocumentText = string.Format(html, "https://www.youtube.com/watch?v=5dFvl3mS8-U".Split('=')[1]);Thanks
Ramco RamcoRank #462 · 5.4K reputationPosted Nov 14, 2022, 10:01 PM EST
Hi
On below line i am getting error - object reference not set to an instance of the object.
this.webBrowser1.DocumentText = string.Format(html, "htp:/www.youtube.com/watch?v=MYojqnJ34g4".Split('=')[1]);
Thanks