int.ToString() does not exist. Why?

A

axkixx

For whatever reason, I keep getting error of int.ToString() not
existing. Why not?
Has anyone encountered this problem before?
 
M

Michael Nemtsev

Hello (e-mail address removed),

Any code sample?
For whatever reason, I keep getting error of int.ToString() not
existing. Why not?
Has anyone encountered this problem before?

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
G

Guest

ToString() is a non-static method, and so you need an object reference (an
instance), you can't call the method on the type itself.


So "int.ToString()" won't work, while

int i = 10;
i.ToString(); will work.
Peter
 
A

axkixx

Sorry. The title of the post could be miesleading, but that's what I
did exactly.

int nStartRow = (currentPage * dgTest.PageSize) + 1;
int nEndRow = nStartRow + dgTest.PageSize - 1;

Both nStartRow and nEndRow spit out value correctly as int data type,
but as soon as adding .ToString() method to each, I get the error
saying "nStartRow.ToString() does not exist". or "nStartRow.ToString()
does not exist".
When I view in "Watch" panel in VS.Net.

On error message on the brpwser tells me :
"Exception Details: Exception of type System.Web.HttpUnhandledException
was thrown.

Exception Details: Exception of type System.Web.HttpUnhandledException
was thrown.
Object reference not set to an instance of an object."
 
C

Chris Dunaway

int nStartRow = (currentPage * dgTest.PageSize) + 1;
int nEndRow = nStartRow + dgTest.PageSize - 1;

Both nStartRow and nEndRow spit out value correctly as int data type,
but as soon as adding .ToString() method to each, I get the error
saying "nStartRow.ToString() does not exist". or "nStartRow.ToString()
does not exist".

Show us some more code. Where are you adding the ToString()? We need
more information to help you.
 
A

axkixx

My bad, guys. Although it showed "nStartRow.ToString() does not exist"
in Watch window, the problem was somewhere else.
 
S

Stuart Irving

It isn't static, you will need an instance

int myInt = 0;
Console.Write(myInt.ToString());
 

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