on a windows application I have a txttable that I am trying to write an int in.
It works fine when i send a string to it, it prints it by doing the following
Code:
txtTable.Text = "Hello dealer";
but when i try to send an int variable to it like so
[code]
int x=10;
txtTable.text=x;
[code]
i get the following error
Cannot implicitly convert type 'int' to 'string'
how then can i put this int out to the text box?
Thanks
well thanks
the sarcasm is not needed, I am not an idiot
just new to C# and asking a question, and i did not know about the msdn site
if you are too good for such an answer... then just don't answer
Sheesh
like I said if you don't want to answer a basic question then don't answer it. It is a message board, anyone can answer who wants to. I did not call him up or send a personal email.
And I did try to fix it my self but got stuck, but I did not know how the txttable works thats why I ask for help.
It's ok, I didn't mean to sound rude, it's just that it is *very* basic. If you look at the textbox's "Text" property, you can see that it is of type string. So, that means that you cannot assign an integer to it. A simple search for "Convert integer to string" would have pulled up thousands of results.
well thanks
the sarcasm is not needed, I am not an idiot
just new to C# and asking a question, and i did not know about the msdn site
if you are too good for such an answer... then just don't answer
Sheesh
Not knowing about the MSDN site means you did NOT read the documentation that comes with the product.
So that would either indicate that you already believe you know Everything about the product or ...... well' lets just say your post has an inaccuracy....
I am sure this post has added you to the ignore list of many many people.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!) 2008, 2009 In theory, there is no difference between theory and paractice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
Looking to your former posts i have seen you obviously changed from C++ to C# now.So you have to know: C# is different to C++ in a lot of things. Therefor I would recommand you ( even if you are maybe an expierenced programmer in another language ) take a beginners book like 'MS Visual C# 2005 Step by Step' ( Maybe in between its Visual C#2008 step by step , I dont know ) It will not need for long to get all this basics in and after that it will be much easier for you to use C#.
In comparing C# to older languages like VB 6.0 where it was no problem to do
Code:
Dim x as Integer
Textbox1.Text = X
This is not possible in C#. C# is very exact in types and as you see and will learn to love,the intellisense is very pregnant and exact. If your intellisense doesn't show you the variable you already have defined when typing the first few letters of it, something is wrong like you may have defined the variable within a loop or an ' if ' condition and now trying to use it outside of it, or something others which isn't allowed in C# and was no problem in C++ or VB.
Trying to compile you will get the errormessages, but you can see problems very often before even compiling by having an eye on the intellisense.
This should only be a hint for some very new C# users.
Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ? My latest articles : Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
Bookmarks