Error In Command Window - Method does not exist

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mythran

    #1

    Error In Command Window - Method does not exist

    I have the following code:

    [STAThread()]
    public static void Main()
    {
    DoIt();
    }

    private void DoIt()
    {
    string text = "This is a string.";

    // Place a breakpoint on the following line and debug.
    Console.WriteLi ne("Text: " + text);
    }

    When I debug and break on the Console.WriteLi ne line, and then type in the
    Command Window - Immediate pane the following:

    ? text.Substring( 0, 2)

    I get:

    error: 'text.Substring ' does not exist


    Hmm, why?

    Thanks,
    Mythran

  • Mohammad Shalabi

    #2
    Re: Error In Command Window - Method does not exist

    Hi,
    does this code compiles correctly?
    the code for the main needs to point to an object, or a staic method.
    public static void main()
    {
    class1 c = new class1();
    C.DoIt();
    }
    or you change the DoTI to static method.

    thnak you.
    "Mythran" <kip_potter@hot mail.comREMOVET RAIL> wrote in message
    news:uTCN$g1UGH A.5500@TK2MSFTN GP12.phx.gbl...[color=blue]
    >I have the following code:
    >
    > [STAThread()]
    > public static void Main()
    > {
    > DoIt();
    > }
    >
    > private void DoIt()
    > {
    > string text = "This is a string.";
    >
    > // Place a breakpoint on the following line and debug.
    > Console.WriteLi ne("Text: " + text);
    > }
    >
    > When I debug and break on the Console.WriteLi ne line, and then type in the
    > Command Window - Immediate pane the following:
    >
    > ? text.Substring( 0, 2)
    >
    > I get:
    >
    > error: 'text.Substring ' does not exist
    >
    >
    > Hmm, why?
    >
    > Thanks,
    > Mythran
    >[/color]


    Comment

    • Mythran

      #3
      Re: Error In Command Window - Method does not exist


      "Mohammad Shalabi" <mshalabi@micro soft.com> wrote in message
      news:%23OwWSD4U GHA.4864@TK2MSF TNGP12.phx.gbl. ..[color=blue]
      > Hi,
      > does this code compiles correctly?
      > the code for the main needs to point to an object, or a staic method.
      > public static void main()
      > {
      > class1 c = new class1();
      > C.DoIt();
      > }
      > or you change the DoTI to static method.
      >
      > thnak you.
      > "Mythran" <kip_potter@hot mail.comREMOVET RAIL> wrote in message
      > news:uTCN$g1UGH A.5500@TK2MSFTN GP12.phx.gbl...[color=green]
      >>I have the following code:
      >>
      >> [STAThread()]
      >> public static void Main()
      >> {
      >> DoIt();
      >> }
      >>
      >> private void DoIt()
      >> {
      >> string text = "This is a string.";
      >>
      >> // Place a breakpoint on the following line and debug.
      >> Console.WriteLi ne("Text: " + text);
      >> }
      >>
      >> When I debug and break on the Console.WriteLi ne line, and then type in
      >> the Command Window - Immediate pane the following:
      >>
      >> ? text.Substring( 0, 2)
      >>
      >> I get:
      >>
      >> error: 'text.Substring ' does not exist
      >>
      >>
      >> Hmm, why?
      >>
      >> Thanks,
      >> Mythran
      >>[/color]
      >
      >[/color]

      Grr, I knew I should have copied and paste the code ... anywho, create the
      object, put the call to DoIt() into a non-static public method, and run it
      :) I still get the same error..

      Mythran

      Comment

      • Arif Khan

        #4
        Re: Error In Command Window - Method does not exist

        I tried it and it's giving me same errror. Here are my obersations:

        1. text.Length works fine.
        2. Doing exactly same thing i.e. ?text.Substring (0,2) from VB.NET console
        application in VS.NET 2003 works fine.
        3. Doing exactly same thing i.e. ?text.Substring (0,2) from Visual Studio
        2005 for both C# and Vb.net console application works fine.

        Somehow calling a function from VS.NET 2003 c# application's immediate
        window is generating an error. I am not 100% sure but looks like a bug to me.

        Thanks, Arif

        "Mythran" wrote:
        [color=blue]
        >
        > "Mohammad Shalabi" <mshalabi@micro soft.com> wrote in message
        > news:%23OwWSD4U GHA.4864@TK2MSF TNGP12.phx.gbl. ..[color=green]
        > > Hi,
        > > does this code compiles correctly?
        > > the code for the main needs to point to an object, or a staic method.
        > > public static void main()
        > > {
        > > class1 c = new class1();
        > > C.DoIt();
        > > }
        > > or you change the DoTI to static method.
        > >
        > > thnak you.
        > > "Mythran" <kip_potter@hot mail.comREMOVET RAIL> wrote in message
        > > news:uTCN$g1UGH A.5500@TK2MSFTN GP12.phx.gbl...[color=darkred]
        > >>I have the following code:
        > >>
        > >> [STAThread()]
        > >> public static void Main()
        > >> {
        > >> DoIt();
        > >> }
        > >>
        > >> private void DoIt()
        > >> {
        > >> string text = "This is a string.";
        > >>
        > >> // Place a breakpoint on the following line and debug.
        > >> Console.WriteLi ne("Text: " + text);
        > >> }
        > >>
        > >> When I debug and break on the Console.WriteLi ne line, and then type in
        > >> the Command Window - Immediate pane the following:
        > >>
        > >> ? text.Substring( 0, 2)
        > >>
        > >> I get:
        > >>
        > >> error: 'text.Substring ' does not exist
        > >>
        > >>
        > >> Hmm, why?
        > >>
        > >> Thanks,
        > >> Mythran
        > >>[/color]
        > >
        > >[/color]
        >
        > Grr, I knew I should have copied and paste the code ... anywho, create the
        > object, put the call to DoIt() into a non-static public method, and run it
        > :) I still get the same error..
        >
        > Mythran
        >
        >[/color]

        Comment

        • Mythran

          #5
          Re: Error In Command Window - Method does not exist


          "Arif Khan" <ArifKhan@discu ssions.microsof t.com> wrote in message
          news:E475E4FE-27BF-45D0-AA0B-26DDCD36A26B@mi crosoft.com...[color=blue]
          >I tried it and it's giving me same errror. Here are my obersations:
          >
          > 1. text.Length works fine.
          > 2. Doing exactly same thing i.e. ?text.Substring (0,2) from VB.NET console
          > application in VS.NET 2003 works fine.
          > 3. Doing exactly same thing i.e. ?text.Substring (0,2) from Visual Studio
          > 2005 for both C# and Vb.net console application works fine.
          >
          > Somehow calling a function from VS.NET 2003 c# application's immediate
          > window is generating an error. I am not 100% sure but looks like a bug to
          > me.
          >
          > Thanks, Arif
          >[/color]

          Thanks :) Thought it was but had to check to make sure I wasn't doing
          something wrong :)

          Mythran

          Comment

          Working...