473,408 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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 260025

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nathan | last post by:
Is there a way to convert a string to a CipherMessage? I am calling a function that decrypts a CipherMessage and returns the value. The only problem is when I want to use an encrypted value stored...
3
by: news.hku.hk | last post by:
could you tell me how can i convet a string to integer?? #include <iostream> #include <string> using namespace std; int main(){ int integer; string buffer("123456789");
5
by: sarab | last post by:
Hi, I have a managed C++ app in which i need to convert String * to char *. How can i achive this?. regards -sarab
3
by: Petr Jakes | last post by:
Hi, I am trying to convert string to the "escaped string". example: from "0xf" I need "\0xf" I am able to do it like: a="0xf" escaped_a=("\%s" % a ).decode("string_escape") But it looks a...
5
by: XML newbie: Urgent pls help! | last post by:
function to convert string to 1 dimensional array of long in VB.Net
3
by: Ursula | last post by:
Is it possible to convert a string in a file. The problem is this: I have an object string that is a file xml and I want to pass to Deserialize function, but Deserialize function expect an object...
3
by: Shawn Ferguson | last post by:
Hello All, I'm trying to do what I would think would be simple and straightforward, but it is not. I have a 2 textbox on a form, a label, and a button, when I click the botton I want to add the...
4
by: Man4ish | last post by:
HI , I am trying to convert string into char array of characters.but facing problem. #include <iostream> #include <string> using namespace std; int main() { string t="1,2,3,4,5,6";
12
by: Peter | last post by:
Trying to convert string to byte array. the following code returns byte array of {107, 62, 194, 139, 64} how can I convert this string to a byte array of {107, 62, 139, 65} ...
9
by: engteng | last post by:
How do I convert string to numeric in VB.NET 2003 ? Example convert P50001 to 50001 or 50001P to 50001 but if P is in middle then not convert. Regards, Tee
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.