Serenity
Serenity

Reputation: 5098

Need help with error:: The best overloaded method match for 'int.Parse(string)' has some invalid arguments

dsgetQuesTypeID = objdalQuesTypeID.GetQuesTypeID(int.Parse(QuesTypeID)); //error here

Whats wrong ?

Upvotes: 0

Views: 7597

Answers (3)

TalentTuner
TalentTuner

Reputation: 17556

if you see the int.Parse in metadata explorer

      //
    // Summary:
    //     Converts the string representation of a number to its 32-bit signed integer
    //     equivalent.
    //
    // **Parameters:
    //   s:
    //     A string containing a number to convert.**
    //
    // Returns:
    //     A 32-bit signed integer equivalent to the number contained in s.
    //

    public static int Parse(string s);

it requires a string input to be parsed , but QuesTypeID is int so that's why no overloaded method is found so to correct the problem , you need to do following

int.Parse(QuesTypeID.ToString());

Upvotes: 2

Dean Chalk
Dean Chalk

Reputation: 20471

You maybe passing null value into GetQuesTypeID(string QuesTypeID)

Upvotes: 0

Adrian Fâciu
Adrian Fâciu

Reputation: 12562

You have a member with the same name QuesTypeID as the name of the variable passed to the method. One is int and one is String. Try to rename the variable from the method to something else, like: quesTypeID. I think this would solve your problem. Also you should use Int.TryParse instead of Int.Parse.

Upvotes: 2

Related Questions