Error In Command Window - Method does not exist

M

Mythran

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.WriteLine("Text: " + text);
}

When I debug and break on the Console.WriteLine 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
 
M

Mohammad Shalabi

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.
 
M

Mythran

Mohammad Shalabi said:
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 said:
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.WriteLine("Text: " + text);
}

When I debug and break on the Console.WriteLine 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

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
 
G

Guest

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 said:
Mohammad Shalabi said:
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 said:
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.WriteLine("Text: " + text);
}

When I debug and break on the Console.WriteLine 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

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
 
M

Mythran

Arif Khan said:
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

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

Mythran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top