469,341 Members | 7,742 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,341 developers. It's quick & easy.

convert int to string

How do I get the string representation of an int? for example

int var1 = 2;

string var2 = var1.ToString;

I'm wanting var2 to be "2"

I get the compile error:
Error 1 Cannot convert method group 'ToString' to non-delegate type
'string'. Did you intend to invoke the method?

Thanks.

--
mo*******@nospam.nospam
Jan 24 '06 #1
5 259505

moondaddy wrote:
How do I get the string representation of an int? for example

int var1 = 2;

string var2 = var1.ToString;

I'm wanting var2 to be "2"

I get the compile error:
Error 1 Cannot convert method group 'ToString' to non-delegate type
'string'. Did you intend to invoke the method?


ToString is a method, not a property.

string var2 = var1.ToString();

Matt

Jan 24 '06 #2
ToString()
"moondaddy" <mo*******@nospam.nospam> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
How do I get the string representation of an int? for example

int var1 = 2;

string var2 = var1.ToString;

I'm wanting var2 to be "2"

I get the compile error:
Error 1 Cannot convert method group 'ToString' to non-delegate type
'string'. Did you intend to invoke the method?

Thanks.

--
mo*******@nospam.nospam

Jan 24 '06 #3
Hello moondaddy,

var1.ToString()

u can try Convert.ToString(var1)

m> How do I get the string representation of an int? for example
m>
m> int var1 = 2;
m>
m> string var2 = var1.ToString;
m>
m> I'm wanting var2 to be "2"
m>
m> I get the compile error:
m> Error 1 Cannot convert method group 'ToString' to non-delegate type
m> 'string'. Did you intend to invoke the method?
m> Thanks.
m>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/members/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Jan 24 '06 #4
Thanks.

--
mo*******@nospam.nospam
"moondaddy" <mo*******@nospam.nospam> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
How do I get the string representation of an int? for example

int var1 = 2;

string var2 = var1.ToString;

I'm wanting var2 to be "2"

I get the compile error:
Error 1 Cannot convert method group 'ToString' to non-delegate type
'string'. Did you intend to invoke the method?

Thanks.

--
mo*******@nospam.nospam

Jan 24 '06 #5
Hi Moondaddy,

We could use ToString method to achieve this goal. Just like following:
int var1 = 2;
string var2 = var1.ToString();

I hope the above information is helpful for you. Thanks and have a nice day!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security

--------------------
From: "moondaddy" <mo*******@nospam.nospam>
Subject: convert int to string
Date: Tue, 24 Jan 2006 12:17:30 -0600
Lines: 18
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
Message-ID: <#g*************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: cpe-24-175-64-176.houston.res.rr.com 24.175.64.176
Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.languages.csharp:380948
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

How do I get the string representation of an int? for example

int var1 = 2;

string var2 = var1.ToString;

I'm wanting var2 to be "2"

I get the compile error:
Error 1 Cannot convert method group 'ToString' to non-delegate type
'string'. Did you intend to invoke the method?

Thanks.

--
mo*******@nospam.nospam


Jan 25 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Nathan | last post: by
3 posts views Thread by news.hku.hk | last post: by
5 posts views Thread by sarab | last post: by
3 posts views Thread by Petr Jakes | last post: by
5 posts views Thread by XML newbie: Urgent pls help! | last post: by
3 posts views Thread by Ursula | last post: by
3 posts views Thread by Shawn Ferguson | last post: by
12 posts views Thread by Peter | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.