Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Convert does not contain a definition for "toString"

Tags:

c#

oop

asp.net

I am trying to convert a value to a string, as far as I can tell, I have to use the method toString, of the class Convert, of the namespace System.

Here's my code:

Compiler Error Message: CS0117: 'System.Convert' does not contain a definition for 'toString'

Source Error:


Line 101:                while (r.Read())
Line 102:                {
Line 103:                    listbox.Items.Add(new ListItem(Convert.toString(r["first_name"]), Convert.toString(r["first_name"])));
Line 104:                }

What am I doing wrong exactly? I'm new to C# (hence why, if you look at my profile you see like 6-7 questions, all related to C# lately!). It's really making me practice my OOP chops too!

like image 898
Steven Matthews Avatar asked Dec 17 '25 07:12

Steven Matthews


2 Answers

C# is case sensitive try this

Convert.ToString()
like image 128
rs. Avatar answered Dec 19 '25 19:12

rs.


Get rid of the

Convert.toString(r["first_name"])

and change it to

r["first_name"].ToString()

Edited to rid the world of this nasty little typo :)

like image 37
Darren Wainwright Avatar answered Dec 19 '25 20:12

Darren Wainwright



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!