By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,158 Members | 1,325 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,158 IT Pros & Developers. It's quick & easy.

Error In Command Window - Method does not exist

P: n/a
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

Mar 29 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:uT**************@TK2MSFTNGP12.phx.gbl...
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

Mar 29 '06 #2

P: n/a

"Mohammad Shalabi" <ms******@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:uT**************@TK2MSFTNGP12.phx.gbl...
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

Mar 29 '06 #3

P: n/a
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:

"Mohammad Shalabi" <ms******@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:uT**************@TK2MSFTNGP12.phx.gbl...
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

Mar 30 '06 #4

P: n/a

"Arif Khan" <Ar******@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
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

Mar 30 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.