Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1178
  • Last Modified:

StringBuilder

getting two errors that strike me as odd on a snip of code dealing with the Visual Studio 05/C# 2.0 StringBuilder method.

The Code:
protected void btnRequestSubmit_Click(object sender, EventArgs e)
    {
        StringBuilder sBuild = new StringBuilder(); /*  line 57 */

        sBuild.Append("<p><strong>Results:</strong> "); /*  line 59 */
        sbuild.Append(ddlRequestType.SelectedItem.Value); /*  line 60 */
        sBuild.Append("</p>"); /*  line 61 */

        lblDisplayResults.Text = sBuild.ToString; /*  line 63 */
    }

The errors:
    The name 'sbuild' does not exist in the current context - Line 60
    Cannot convert method group 'ToString' to non-delegate type 'string'. Did you intend to invoke the method? - Line 63

I know in .Net 1.1/1.0 I was able to use the StringBuilder in the fashion listed above, with no detriment. What am I doing wrong now?

0
Paul Kahl
Asked:
Paul Kahl
4 Solutions
 
mrichmonCommented:
Have you included the proper references to use StringBuilder?
0
 
rivusglobalCommented:
sBuild.Append("<p><strong>Results:</strong> "); /*  line 59 */
sbuild.Append(ddlRequestType.SelectedItem.Value); /*  line 60 */

Line 60 sbuild, should be sBuild.Append(ddlRequestType.SelectedItem.Value);

Maybe you caught this, maybe you didn't. Thought i'd put it out there.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You have a case typo...

This:

    sbuild

should be:

    sBuild

Notice the uppercase "B"?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Paul KahlAuthor Commented:
caught the case issue. That still leaves the second error: Cannot convert method group 'ToString' to non-delegate type 'string'.
0
 
Paul KahlAuthor Commented:
and I have "using System.Text;" at the top of the page, so yes, i'm referencing.
0
 
rivusglobalCommented:
lblDisplayResults.Text = sBuild.ToString; /*  line 63 */

Will work as,

lblDisplayResults.Text = sBuild.ToString(); /*  line 63 */
0
 
Paul KahlAuthor Commented:
Thanks a bunch. The syntax is still very new to me. I switched from VB to C# only about a week ago, so it's a learning curve from hell.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now