开发者

Is this correct syntax for a C# statment

开发者 https://www.devze.com 2023-02-02 09:43 出处:网络
Is this the correct synta开发者_JAVA百科x for a C statment. I recieve the following error message in Visual Studios when trying to use it.

Is this the correct synta开发者_JAVA百科x for a C statment. I recieve the following error message in Visual Studios when trying to use it.

intResult = Convert.ToInt32(cmdSelect.Parameters("RETURN_VALUE").Value);
non-invocable memeber of System.Data.SqlClient.SqlCommand.Parameters can not be used as a method.

Can anyone help clear this up.

I am using the following namespaces as well

using System;
using System.Data;
using System.Configuration;
using System.Web.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Web.Security;


You want to use an indexer, not call a function, so you should use square brackets:

intResult = Convert.ToInt32(cmdSelect.Parameters["RETURN_VALUE"].Value);


In C#, indexers use square brackets, not parentheses as in VB.NET. This should do the trick:

intResult = Convert.ToInt32(cmdSelect.Parameters["RETURN_VALUE"].Value);


Should be:

intResult = Convert.ToInt32(cmdSelect.Parameters["RETURN_VALUE"].Value);


Use the [] index operators on Parameters instead of parentheses:

intResult = Convert.ToInt32(cmdSelect.Parameters["RETURN_VALUE"].Value);


cmdSelect.Parameters["RETURN_VALUE"].Value

indexors are [] in c#, in VB.net they are ()

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号