Okay so I'm writing a windows form application that gathers data from a web sites html source code.
It needs to grab the gender of the person, but some people do not have a gender set so the gender doesn't show in the source code so it's throwing me an error.
What I'm wanting to do instead is if source code does not contain "gender" then Console.Write = "N/A"
.
Here is the code I currently have / am using to capture the data for gender.
JObject ob = JObject.Parse(html);
ob = JObject.Parse(html);
Console.WriteLine(html);
gt.gender = (string)ob["data"]["user"]["gender"];
Console.WriteLine(gt.gender);
I'm still kind of new to this so I'm wondering if there is some sort of if or else statement I could use there so it's not going to throw me an error in my application if the source code does not contain "gender".
Much appreciated.