Are you referring to string, as in the text, or String, as in the title? They are completely different things. How to convert each to a value is different.
String params;
if (params = e.serviceRequest()) {
params = params.substring(1,99); // Here input is "1F2EE56C"
params = "0x" + params;
irsend.sendNEC(params, 32); // error: no matching function for call to 'IRsend::sendNEC(String&, int)'
....
Snippets-r-us.com might be able to help you based on snippets. I can't. What type is e? If that is code for an Arduino with ENCJ ethernet shield, e.serviceRequest() returns a pointer to a NULL terminated array of chars, also known as a string. There is NO reason to copy that data into a String that you can't use. "0x8166817E" is NOT anywhere near equal to 0x8166817E. The strtol() function can take a string ("8166817E") and convert it to a number (0x8166817E). But it will NOT take a String. So, quit with the Strings.
wrun:
But sendNEC get (Hex, Int), How to "convert" type?
I have no idea what you mean by this. It would be best to use real code, not pseudo code, to demonstrate the problem. For example, what is the actual declaration of the method sendNEC()?
Why? The e.serviceRequest() method returns a perfectly usable pointer to char array. Wrapping that char array in a String then is a waste of resources.
But is not good for use mane IF (or CASE)...
Why not? How many switches are there on the remote?
Put the code to figure out what to do with the e.ServiceRequest() pointer in a function, make sure that the function works for all input, and then forget about it.
Converting the string to a number, as guix suggests doesn't reduce the number of cases which is the same as the number of if/else if statements you would need.
Of course, using else if, instead of a new if, would speed up the decision process. That process would stop as soon as a match was found.