On 10-05-2011 17:37, Tony Johansson wrote:
> "Tony Johansson"<(E-Mail Removed)> skrev i meddelandet
> news:iqc9cd$ruk$(E-Mail Removed)...
>> Hello!
>>
>> If I do the following I get compile error says It's not possible to
>> implicit
>> convert the type string to bool
>> Label4.Text = "Browser support cookies : " + Request.Browser.Cookies ?
>> "true" : "false";
>>
>> Can I write in another way so I can remove the s string in this code.
>>
>>
>> protected void Page_Load(object sender, EventArgs e)
>> {
>> string s;
>> Label1.Text = "Application path is : " + Request.Path;
>> Label2.Text = "OS platform is : " + Request.Browser.Platform;
>> Label3.Text = "Browser type is : " + Request.Browser.Type;
>> s = Request.Browser.Cookies ? "true" : "false";
>> Label4.Text = "Browser support cookies : " + s;
>> s = Request.Browser.VBScript ? "true" : "false";
>> Label5.Text = "Browser support VBScript : " + s;
>> s = Request.Browser.JavaScript ? "true" : "false";
>> Label6.Text = "Browser support JavaScript : " + s;
>> Label7.Text = "Browser is using :" + Request.HttpMethod + " data
>> transfer method";
>> }
> I found it myself I just used Convert.ToString in this way.
> Label4.Text = "Browser support cookies :" +
> Convert.ToString(Request.Browser.Cookies ? true : false);
That code can be shortened!
Label4.Text = "Browser support cookies :" + Request.Browser.Cookies;
works the same way.
Arne
|