string.trim not working c#
Posted on 2011-10-27
Right I've been working with vb.net for quite a few years now but have decided i need to get into c# big time so am converting a website i stated in vb over to c# to get some practice while finishing it off.
I'm having a few syntax issues so wondered if someone could have a look as based on m vb knowledge cant see whats wrong?!
I have the following vb function which works fine:
Protected Sub btnSearch_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles btnSearch.Click
If Not txtSearch.Text.Trim = "" And LCase(txtSearch.Text) = "search our costumes" Then
Response.Redirect("~/FancyDressSearch/" & txtSearch.Text.Trim.Replace(" ", " ").Replace(" ", "_"))
I then used a convertor and got:
protected void btnSearch_Click(object sender, System.Web.UI.ImageClickEventArgs e)
if ((!txtSearch.Text.Equals("")) & (string.Compare(txtSearch.Text,"search our costumes",true) != 0))
Response.Redirect("~/FancyDressSearch/" + txtSearch.Text.Trim.Replace(" ", " ").Replace(" ", "_"));
Error 36 'string.Trim()' is a 'method', which is not valid in the given context
this is on: txtSearch.Text.Trim.Replace
I cant see anything wrong with that?
Thanks in advance.