none
String is a class type and cannot be used as an expression (Visual studio 2010 express for windows phone)

    Question

    • I typed the following C# code in microsoft visual studio 2010 express for windows phone . The source for this can be found at http://msdn.microsoft.com/en-us/library/ff402526(v=vs.92).aspx

      Private Sub Button1_Click(sender As System.Object, e As RoutedEventArgs)
      String site = TextBox1.Text
      WebBrowser1.Navigate(New Uri(site, UriKind.Absolute))

      I get an error saying that String is a class type and cannot be used as an expression and in this line WebBrowser1.Navigate(New Uri(site, UriKind.Absolute)) i get an error saying 'site is not declared. It may be inaccesible due to its protection level'. Please help me out with this

    Thursday, July 12, 2012 2:59 PM

All replies

  • > I typed the following C# code
    Let's see ...

    > Private Sub Button1_Click(sender As System.Object, e As RoutedEventArgs)
    This is VB

    > String site = TextBox1.Text
    This is C#, but missing a semicolon

    > WebBrowser1.Navigate(New Uri(site, UriKind.Absolute))
    This is VB. Or C# with a missing semicolon
    Thursday, July 12, 2012 3:29 PM
  • But then, why have they given the sample that contains a mix of VB and C# in the link that I've provided above
    Thursday, July 12, 2012 3:50 PM
  • All the lines that you mentioned have the semicolon
    Thursday, July 12, 2012 3:51 PM
  • You need to use "string" with lower case s, exactly as in the sample. "String" (with upper case S) is indeed a class type.


    Richard Woo
    Thursday, July 12, 2012 3:54 PM
  • Even though I type string it automatically takes it as String, how do I prevent that from happening.
    Thanks in advance
    Thursday, July 12, 2012 3:59 PM
  • If I had to type out this entire thing only in VB or only in C#  how would it look then?
    Thursday, July 12, 2012 4:04 PM
  • Even though I type string it automatically takes it as String
    Then you're working with a VB.NET project, not a C# project.
    Thursday, July 12, 2012 4:11 PM

  • I want to do just as it is in the tutorial that I've posted in my question.

    Can you please guide me as to how to choose the settings in the visual studio so that I can make the project in the C# platform only.
    Is there any option of that sort

    Thank you all  for the instant replies :)

    Thursday, July 12, 2012 4:20 PM
  • You'll need to start a new project and make sure you're under the Visual C# | Silverlight for Windows Phone node under Installed Templates.
    Thursday, July 12, 2012 4:49 PM
  • hmm, got it. Thanks a lot :)
    I was searching for this particular thing the whole day.
    Thanks again :)
    Thursday, July 12, 2012 4:55 PM